|
|
@ -18,14 +18,14 @@ namespace Microsoft.eShopWeb.Web.Services |
|
|
public class CatalogService : ICatalogService |
|
|
public class CatalogService : ICatalogService |
|
|
{ |
|
|
{ |
|
|
private readonly ILogger<CatalogService> _logger; |
|
|
private readonly ILogger<CatalogService> _logger; |
|
|
private readonly IRepository<CatalogItem> _itemRepository; |
|
|
private readonly IAsyncRepository<CatalogItem> _itemRepository; |
|
|
private readonly IAsyncRepository<CatalogBrand> _brandRepository; |
|
|
private readonly IAsyncRepository<CatalogBrand> _brandRepository; |
|
|
private readonly IAsyncRepository<CatalogType> _typeRepository; |
|
|
private readonly IAsyncRepository<CatalogType> _typeRepository; |
|
|
private readonly IUriComposer _uriComposer; |
|
|
private readonly IUriComposer _uriComposer; |
|
|
|
|
|
|
|
|
public CatalogService( |
|
|
public CatalogService( |
|
|
ILoggerFactory loggerFactory, |
|
|
ILoggerFactory loggerFactory, |
|
|
IRepository<CatalogItem> itemRepository, |
|
|
IAsyncRepository<CatalogItem> itemRepository, |
|
|
IAsyncRepository<CatalogBrand> brandRepository, |
|
|
IAsyncRepository<CatalogBrand> brandRepository, |
|
|
IAsyncRepository<CatalogType> typeRepository, |
|
|
IAsyncRepository<CatalogType> typeRepository, |
|
|
IUriComposer uriComposer) |
|
|
IUriComposer uriComposer) |
|
|
@ -46,13 +46,13 @@ namespace Microsoft.eShopWeb.Web.Services |
|
|
new CatalogFilterPaginatedSpecification(itemsPage * pageIndex, itemsPage, brandId, typeId); |
|
|
new CatalogFilterPaginatedSpecification(itemsPage * pageIndex, itemsPage, brandId, typeId); |
|
|
|
|
|
|
|
|
// the implementation below using ForEach and Count. We need a List.
|
|
|
// the implementation below using ForEach and Count. We need a List.
|
|
|
var itemsOnPage = _itemRepository.List(filterPaginatedSpecification).ToList(); |
|
|
var itemsOnPage = await _itemRepository.ListAsync(filterPaginatedSpecification); |
|
|
var totalItems = _itemRepository.Count(filterSpecification); |
|
|
var totalItems = await _itemRepository.CountAsync(filterSpecification); |
|
|
|
|
|
|
|
|
itemsOnPage.ForEach(x => |
|
|
foreach (var itemOnPage in itemsOnPage) |
|
|
{ |
|
|
{ |
|
|
x.PictureUri = _uriComposer.ComposePicUri(x.PictureUri); |
|
|
itemOnPage.PictureUri = _uriComposer.ComposePicUri(itemOnPage.PictureUri); |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
var vm = new CatalogIndexViewModel() |
|
|
var vm = new CatalogIndexViewModel() |
|
|
{ |
|
|
{ |
|
|
|