diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogMockService.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogMockService.cs index 6fdf319c3..8bb6785a6 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogMockService.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogMockService.cs @@ -1,6 +1,5 @@ using eShopOnContainers.Core.Extensions; using eShopOnContainers.Core.Models.Catalog; -using System; using System.Collections.ObjectModel; using System.Linq; using System.Threading.Tasks; @@ -38,13 +37,13 @@ namespace eShopOnContainers.Core.Services.Catalog return MockCatalog; } - public async Task> FilterAsync(string catalogBrand, string catalogType) + public async Task> FilterAsync(int catalogBrandId, int catalogTypeId) { await Task.Delay(500); return MockCatalog - .Where(c => c.CatalogBrand.Equals(catalogBrand, StringComparison.CurrentCultureIgnoreCase) && - c.CatalogType.Equals(catalogType, StringComparison.CurrentCultureIgnoreCase)) + .Where(c => c.CatalogBrandId == catalogBrandId && + c.CatalogTypeId == catalogTypeId) .ToObservableCollection(); } diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogService.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogService.cs index 4b41c7807..fa78f3625 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogService.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogService.cs @@ -17,9 +17,18 @@ namespace eShopOnContainers.Core.Services.Catalog _requestProvider = requestProvider; } - public Task> FilterAsync(string catalogBrand, string catalogType) + public async Task> FilterAsync(int catalogBrandId, int catalogTypeId) { - throw new NotImplementedException(); + UriBuilder builder = new UriBuilder(GlobalSetting.CatalogEndpoint); + + builder.Path = string.Format("api/v1/catalog/items/type/{0}/brand/{1}", catalogTypeId, catalogBrandId); + + string uri = builder.ToString(); + + CatalogRoot catalog = + await _requestProvider.GetAsync(uri); + + return catalog?.Data?.ToObservableCollection(); } public async Task> GetCatalogAsync() diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/ICatalogService.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/ICatalogService.cs index e6817a8a9..508da75d8 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/ICatalogService.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/ICatalogService.cs @@ -7,7 +7,7 @@ namespace eShopOnContainers.Core.Services.Catalog public interface ICatalogService { Task> GetCatalogBrandAsync(); - Task> FilterAsync(string catalogBrand, string catalogType); + Task> FilterAsync(int catalogBrandId, int catalogTypeId); Task> GetCatalogTypeAsync(); Task> GetCatalogAsync(); Task GetCatalogItemAsync(string id); diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/CatalogViewModel.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/CatalogViewModel.cs index 5445b8c79..05e2b461a 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/CatalogViewModel.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/CatalogViewModel.cs @@ -110,7 +110,7 @@ namespace eShopOnContainers.Core.ViewModels IsBusy = true; MessagingCenter.Send(this, MessengerKeys.Filter); - Products = await _productsService.FilterAsync(Brand.Brand, Type.Type); + Products = await _productsService.FilterAsync(Brand.Id, Type.Id); IsBusy = false; }