Removing List and all the places it was used

This commit is contained in:
Eric Fleming
2019-03-01 22:07:46 -05:00
parent b8f1ac977d
commit b084d4e770
2 changed files with 7 additions and 8 deletions

View File

@@ -6,7 +6,6 @@ namespace Microsoft.eShopWeb.ApplicationCore.Interfaces
public interface IRepository<T> where T : BaseEntity public interface IRepository<T> where T : BaseEntity
{ {
T GetSingleBySpec(ISpecification<T> spec); T GetSingleBySpec(ISpecification<T> spec);
IEnumerable<T> List(ISpecification<T> spec);
T Add(T entity); T Add(T entity);
void Update(T entity); void Update(T entity);
void Delete(T entity); void Delete(T entity);

View File

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