diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Models/Catalog/CatalogBrand.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Models/Catalog/CatalogBrand.cs index 773c9e2a8..504031c1b 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Models/Catalog/CatalogBrand.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Models/Catalog/CatalogBrand.cs @@ -2,12 +2,12 @@ { public class CatalogBrand { - public int CatalogBrandId { get; set; } - public string Name { get; set; } + public int Id { get; set; } + public string Brand { get; set; } public override string ToString() { - return Name; + return Brand; } } } \ No newline at end of file diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Models/Catalog/CatalogType.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Models/Catalog/CatalogType.cs index 55277463c..c12b17007 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Models/Catalog/CatalogType.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Models/Catalog/CatalogType.cs @@ -2,12 +2,12 @@ { public class CatalogType { - public int CatalogTypeId { get; set; } - public string Name { get; set; } + public int Id { get; set; } + public string Type { get; set; } public override string ToString() { - return Name; + return Type; } } } \ No newline at end of file diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogMockService.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogMockService.cs index 19447bc6a..6fdf319c3 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogMockService.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogMockService.cs @@ -12,14 +12,14 @@ namespace eShopOnContainers.Core.Services.Catalog { private ObservableCollection MockCatalogBrand = new ObservableCollection { - new CatalogBrand { CatalogBrandId = 1, Name = "Azure" }, - new CatalogBrand { CatalogBrandId = 2, Name = "Visual Studio" } + new CatalogBrand { Id = 1, Brand = "Azure" }, + new CatalogBrand { Id = 2, Brand = "Visual Studio" } }; private ObservableCollection MockCatalogType = new ObservableCollection { - new CatalogType { CatalogTypeId = 1, Name = "Mug" }, - new CatalogType { CatalogTypeId = 2, Name = "T-Shirt" } + new CatalogType { Id = 1, Type = "Mug" }, + new CatalogType { Id = 2, Type = "T-Shirt" } }; private ObservableCollection MockCatalog = new ObservableCollection diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogService.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogService.cs index a629cdb58..4b41c7807 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogService.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogService.cs @@ -4,6 +4,7 @@ using System.Threading.Tasks; using eShopOnContainers.Core.Models.Catalog; using eShopOnContainers.Core.Services.RequestProvider; using eShopOnContainers.Core.Extensions; +using System.Collections.Generic; namespace eShopOnContainers.Core.Services.Catalog { @@ -11,18 +12,6 @@ namespace eShopOnContainers.Core.Services.Catalog { private readonly IRequestProvider _requestProvider; - private ObservableCollection MockCatalogBrand = new ObservableCollection - { - new CatalogBrand { CatalogBrandId = 1, Name = "Azure" }, - new CatalogBrand { CatalogBrandId = 2, Name = "Visual Studio" } - }; - - private ObservableCollection MockCatalogType = new ObservableCollection - { - new CatalogType { CatalogTypeId = 1, Name = "Mug" }, - new CatalogType { CatalogTypeId = 2, Name = "T-Shirt" } - }; - public CatalogService(IRequestProvider requestProvider) { _requestProvider = requestProvider; @@ -41,8 +30,6 @@ namespace eShopOnContainers.Core.Services.Catalog string uri = builder.ToString(); - System.Diagnostics.Debug.WriteLine(uri); - CatalogRoot catalog = await _requestProvider.GetAsync(uri); @@ -56,16 +43,30 @@ namespace eShopOnContainers.Core.Services.Catalog public async Task> GetCatalogBrandAsync() { - await Task.Delay(500); + UriBuilder builder = new UriBuilder(GlobalSetting.CatalogEndpoint); - return MockCatalogBrand; + builder.Path = "api/v1/catalog/catalogbrands"; + + string uri = builder.ToString(); + + IEnumerable brands = + await _requestProvider.GetAsync>(uri); + + return brands?.ToObservableCollection(); } public async Task> GetCatalogTypeAsync() { - await Task.Delay(500); + UriBuilder builder = new UriBuilder(GlobalSetting.CatalogEndpoint); + + builder.Path = "api/v1/catalog/catalogtypes"; + + string uri = builder.ToString(); + + IEnumerable types = + await _requestProvider.GetAsync>(uri); - return MockCatalogType; + return types?.ToObservableCollection(); } } } diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/CatalogViewModel.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/CatalogViewModel.cs index bbdfea6ec..5445b8c79 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.Name, Type.Name); + Products = await _productsService.FilterAsync(Brand.Brand, Type.Type); IsBusy = false; }