public async Task <IEnumerable <CatalogItemViewModel> > GetCatalogItemsAsync(ClaimsPrincipal user) { ISpecification <CatalogItem> listSpecification; //if (user.IsInPartnerRole()) //{ // var ownerId = user.FindFirstValue(Constants.ClaimTypes.OwnerIdentifier); // listSpecification = new CatalogItemForOwnerSpecification(ownerId); //} //else //{ // listSpecification = new AllCatalogItemsSpecification(); //} listSpecification = new AllCatalogItemsSpecification(); var catalogItems = await _catalogItemRepository.ListAsync(listSpecification); return(catalogItems.Select(catalogItem => { var newItem = _manager.GetIndustry().ConvertItem(catalogItem); return new CatalogItemViewModel { Id = newItem.Id, OwnerId = newItem.OwnerId, ProductId = newItem.ProductId, ProductName = newItem.ProductName, ProductPictureUrl = newItem.ProductPictureUrl, ProductAllergyInfo = newItem.ProductAllergyInfo }; })); }
public async Task <IEnumerable <CatalogItemViewModel> > GetCatalogItemsAsync(ClaimsPrincipal user) { ISpecification <CatalogItem> listSpecification; if (user.IsInPartnerRole()) { var ownerId = user.FindFirstValue(Constants.ClaimTypes.OwnerIdentifier); listSpecification = new CatalogItemForOwnerSpecification(ownerId); } else { listSpecification = new AllCatalogItemsSpecification(); } var catalogItems = await _catalogItemRepository.ListAsync(listSpecification); return(catalogItems.Select(catalogItem => new CatalogItemViewModel { Id = catalogItem.Id, OwnerId = catalogItem.OwnerId, ProductId = catalogItem.ProductId, ProductName = catalogItem.ProductName, ProductPictureUrl = catalogItem.ProductPictureUrl })); }