Browse Source

Integrated mobile app with types and brands API

pull/49/merge
Javier Suárez Ruiz 8 years ago
parent
commit
4d8ccd3c74
5 changed files with 30 additions and 29 deletions
  1. +3
    -3
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Models/Catalog/CatalogBrand.cs
  2. +3
    -3
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Models/Catalog/CatalogType.cs
  3. +4
    -4
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogMockService.cs
  4. +19
    -18
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogService.cs
  5. +1
    -1
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/CatalogViewModel.cs

+ 3
- 3
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Models/Catalog/CatalogBrand.cs View File

@ -2,12 +2,12 @@
{ {
public class CatalogBrand 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() public override string ToString()
{ {
return Name;
return Brand;
} }
} }
} }

+ 3
- 3
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Models/Catalog/CatalogType.cs View File

@ -2,12 +2,12 @@
{ {
public class CatalogType 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() public override string ToString()
{ {
return Name;
return Type;
} }
} }
} }

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

@ -12,14 +12,14 @@ namespace eShopOnContainers.Core.Services.Catalog
{ {
private ObservableCollection<CatalogBrand> MockCatalogBrand = new ObservableCollection<CatalogBrand> 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> 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> private ObservableCollection<CatalogItem> MockCatalog = new ObservableCollection<CatalogItem>


+ 19
- 18
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogService.cs View File

@ -4,6 +4,7 @@ using System.Threading.Tasks;
using eShopOnContainers.Core.Models.Catalog; using eShopOnContainers.Core.Models.Catalog;
using eShopOnContainers.Core.Services.RequestProvider; using eShopOnContainers.Core.Services.RequestProvider;
using eShopOnContainers.Core.Extensions; using eShopOnContainers.Core.Extensions;
using System.Collections.Generic;
namespace eShopOnContainers.Core.Services.Catalog namespace eShopOnContainers.Core.Services.Catalog
{ {
@ -11,18 +12,6 @@ namespace eShopOnContainers.Core.Services.Catalog
{ {
private readonly IRequestProvider _requestProvider; 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) public CatalogService(IRequestProvider requestProvider)
{ {
_requestProvider = requestProvider; _requestProvider = requestProvider;
@ -41,8 +30,6 @@ namespace eShopOnContainers.Core.Services.Catalog
string uri = builder.ToString(); string uri = builder.ToString();
System.Diagnostics.Debug.WriteLine(uri);
CatalogRoot catalog = CatalogRoot catalog =
await _requestProvider.GetAsync<CatalogRoot>(uri); await _requestProvider.GetAsync<CatalogRoot>(uri);
@ -56,16 +43,30 @@ namespace eShopOnContainers.Core.Services.Catalog
public async Task<ObservableCollection<CatalogBrand>> GetCatalogBrandAsync() 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() public async Task<ObservableCollection<CatalogType>> GetCatalogTypeAsync()
{ {
await Task.Delay(500);
UriBuilder builder = new UriBuilder(GlobalSetting.CatalogEndpoint);
builder.Path = "api/v1/catalog/catalogtypes";
string uri = builder.ToString();
IEnumerable<CatalogType> types =
await _requestProvider.GetAsync<IEnumerable<CatalogType>>(uri);
return MockCatalogType;
return types?.ToObservableCollection();
} }
} }
} }

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

@ -110,7 +110,7 @@ namespace eShopOnContainers.Core.ViewModels
IsBusy = true; IsBusy = true;
MessagingCenter.Send(this, MessengerKeys.Filter); MessagingCenter.Send(this, MessengerKeys.Filter);
Products = await _productsService.FilterAsync(Brand.Name, Type.Name);
Products = await _productsService.FilterAsync(Brand.Brand, Type.Type);
IsBusy = false; IsBusy = false;
} }


Loading…
Cancel
Save