public async Task <IZalandoProductsWithPagingInfo> GetArticlesPaged(string searchKeyWord, FilterType filterType = FilterType.NoFilter, int pageNumber = 1, int pageCount = 20) { IZalandoProductsWithPagingInfo zalandoProductItemsWithPaging = InstanceFactory.GetInstance <IZalandoProductsWithPagingInfo>();; using (var client = new HttpClient()) { string repUrl = string.Format("{0}?fullText={1}", _baseUri + _articlesEndPointName, searchKeyWord); HttpResponseMessage response; // switch (filterType) { case FilterType.Male: response = await client.GetAsync(string.Format("{0}&gender={1}&page={2}&pageSize={3}&fields=name%2Ccolor%2Cbrand%2Cunits%2Cmedia", repUrl, filterType.ToString(), pageNumber, pageCount)); break; case FilterType.Female: response = await client.GetAsync(string.Format("{0}&gender={1}&page={2}&pageSize={3}&fields=name%2Ccolor%2Cbrand%2Cunits%2Cmedia", repUrl, filterType.ToString(), pageNumber, pageCount)); break; default: response = await client.GetAsync(string.Format("{0}&page={1}&pageSize={2}&fields=name%2Ccolor%2Cbrand%2Cunits%2Cmedia", repUrl, pageNumber, pageCount)); break; } if (response.IsSuccessStatusCode) { string result = await response.Content.ReadAsStringAsync(); var rootResult = JsonConvert.DeserializeObject <RootObject>(result); var zalandoProductItem = InstanceFactory.GetInstance <IZalandoProductItem>(); ObservableCollection <IZalandoProductItem> zalandoProductItems = new ObservableCollection <IZalandoProductItem>(); if (rootResult != null && rootResult.content != null) { foreach (var item in rootResult.content) { zalandoProductItem.BrandName = item.brand.name; zalandoProductItem.ProductName = item.name; zalandoProductItem.Size = item.units.FirstOrDefault().size; zalandoProductItem.PriceFormatted = item.units.FirstOrDefault().price.formatted; zalandoProductItem.ImageUrl = item.media.images.FirstOrDefault() != null?item.media.images.FirstOrDefault().smallHdUrl : null; zalandoProductItems.Add(zalandoProductItem); zalandoProductItem = InstanceFactory.GetInstance <IZalandoProductItem>(); } zalandoProductItemsWithPaging.TotalPages = rootResult.totalPages; zalandoProductItemsWithPaging.IZalandoProductItems = zalandoProductItems; } } } return(zalandoProductItemsWithPaging); }
public void CreateFakeZalandoData() { ProductItemsWithPagingInfo = new ZalandoProductsWithPagingInfo(); ProductItemsWithPagingInfo.IZalandoProductItems = new List <ZalandoProductItem> { new ZalandoProductItem { BrandName = "Tommy Hilfiger", ProductName = "Test1", Size = "M", PriceFormatted = "22$" }, new ZalandoProductItem { BrandName = "Tommy Hilfiger", ProductName = "Test2", Size = "L", PriceFormatted = "22$" } }; }