Integrated Filter API
This commit is contained in:
parent
84d66877be
commit
0d2ec11c6a
@ -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<ObservableCollection<CatalogItem>> FilterAsync(string catalogBrand, string catalogType)
|
||||
public async Task<ObservableCollection<CatalogItem>> 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();
|
||||
}
|
||||
|
||||
|
@ -17,9 +17,18 @@ namespace eShopOnContainers.Core.Services.Catalog
|
||||
_requestProvider = requestProvider;
|
||||
}
|
||||
|
||||
public Task<ObservableCollection<CatalogItem>> FilterAsync(string catalogBrand, string catalogType)
|
||||
public async Task<ObservableCollection<CatalogItem>> 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<CatalogRoot>(uri);
|
||||
|
||||
return catalog?.Data?.ToObservableCollection();
|
||||
}
|
||||
|
||||
public async Task<ObservableCollection<CatalogItem>> GetCatalogAsync()
|
||||
|
@ -7,7 +7,7 @@ namespace eShopOnContainers.Core.Services.Catalog
|
||||
public interface ICatalogService
|
||||
{
|
||||
Task<ObservableCollection<CatalogBrand>> GetCatalogBrandAsync();
|
||||
Task<ObservableCollection<CatalogItem>> FilterAsync(string catalogBrand, string catalogType);
|
||||
Task<ObservableCollection<CatalogItem>> FilterAsync(int catalogBrandId, int catalogTypeId);
|
||||
Task<ObservableCollection<CatalogType>> GetCatalogTypeAsync();
|
||||
Task<ObservableCollection<CatalogItem>> GetCatalogAsync();
|
||||
Task<CatalogItem> GetCatalogItemAsync(string id);
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user