Integrated mobile app with types and brands API
This commit is contained in:
parent
1d05523617
commit
4d8ccd3c74
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -12,14 +12,14 @@ namespace eShopOnContainers.Core.Services.Catalog
|
||||
{
|
||||
private ObservableCollection<CatalogBrand> MockCatalogBrand = new ObservableCollection<CatalogBrand>
|
||||
{
|
||||
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<CatalogType> MockCatalogType = new ObservableCollection<CatalogType>
|
||||
{
|
||||
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<CatalogItem> MockCatalog = new ObservableCollection<CatalogItem>
|
||||
|
@ -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<CatalogBrand> MockCatalogBrand = new ObservableCollection<CatalogBrand>
|
||||
{
|
||||
new CatalogBrand { CatalogBrandId = 1, Name = "Azure" },
|
||||
new CatalogBrand { CatalogBrandId = 2, Name = "Visual Studio" }
|
||||
};
|
||||
|
||||
private ObservableCollection<CatalogType> MockCatalogType = new ObservableCollection<CatalogType>
|
||||
{
|
||||
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<CatalogRoot>(uri);
|
||||
|
||||
@ -56,16 +43,30 @@ namespace eShopOnContainers.Core.Services.Catalog
|
||||
|
||||
public async Task<ObservableCollection<CatalogBrand>> GetCatalogBrandAsync()
|
||||
{
|
||||
await Task.Delay(500);
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.CatalogEndpoint);
|
||||
|
||||
return MockCatalogBrand;
|
||||
builder.Path = "api/v1/catalog/catalogbrands";
|
||||
|
||||
string uri = builder.ToString();
|
||||
|
||||
IEnumerable<CatalogBrand> brands =
|
||||
await _requestProvider.GetAsync<IEnumerable<CatalogBrand>>(uri);
|
||||
|
||||
return brands?.ToObservableCollection();
|
||||
}
|
||||
|
||||
public async Task<ObservableCollection<CatalogType>> GetCatalogTypeAsync()
|
||||
{
|
||||
await Task.Delay(500);
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.CatalogEndpoint);
|
||||
|
||||
return MockCatalogType;
|
||||
builder.Path = "api/v1/catalog/catalogtypes";
|
||||
|
||||
string uri = builder.ToString();
|
||||
|
||||
IEnumerable<CatalogType> types =
|
||||
await _requestProvider.GetAsync<IEnumerable<CatalogType>>(uri);
|
||||
|
||||
return types?.ToObservableCollection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user