在Web API中传递搜索过滤器参数

时间:2016-02-29 07:31:22

标签: c# asp.net-web-api

我有搜索过滤器参数 像

NO

我希望通过Web API传递,我的代码是

public struct PaperAdFilterParameter : IPaperAdFilterParameter
    {
        public int ID { get; set; }
        public DateTime FromDate { get; set; }
        public DateTime ToDate { get; set; }
        public int CustomerID { get; set; }
        public int PublisherID { get; set; }
        public int PublishTypeID { get; set; }
        public int AdCategoryID { get; set; }
        public int EditionID { get; set; }
        public int UserID { get; set; }

    }

和控制器

 string url = PaperAdUrl.FormatWith("GetListBy?" + paperAdFilterParameter);

            try
            {
                using (var client = WebServer.HttpClient)
                {
                    var response = await client.GetAsync(url);

                    response.EnsureSuccessStatusCode();
                    if (paperAdFilterParameter.ID.IsNotEmpty())
                    {
                        PaperAd paperAd = await response.Content.ReadAsAsync<PaperAd>();
                        paperAdList.Add(paperAd);
                    }
                    else
                    paperAdList = await response.Content.ReadAsAsync<List<PaperAd>>();
                }
            }

我不知道如何传递参数?

0 个答案:

没有答案