Browse Source

Integrated Filter API

pull/49/merge
Javier Suárez Ruiz 8 years ago
parent
commit
0d2ec11c6a
4 changed files with 16 additions and 8 deletions
  1. +3
    -4
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogMockService.cs
  2. +11
    -2
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogService.cs
  3. +1
    -1
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/ICatalogService.cs
  4. +1
    -1
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/CatalogViewModel.cs

+ 3
- 4
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogMockService.cs View File

@ -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();
}


+ 11
- 2
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogService.cs View File

@ -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()


+ 1
- 1
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/ICatalogService.cs View File

@ -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);


+ 1
- 1
src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/CatalogViewModel.cs View File

@ -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…
Cancel
Save