public async Task <ActionResult <Item> > GetItemDTO(Guid id) { var item = User.UserRole().Contains("Admin") ? (await _bll.ItemService.FirstOrDefaultAsync((Guid)id)) : (await _bll.ItemService.FirstOrDefaultAsync((Guid)id, User.UserGuidId())); var brands = User.UserRole().Contains("Admin") ? (await _bll.BrandService.AllAsync()) : (await _bll.BrandService.AllAsync(User.UserGuidId())); if (item == null) { return(NotFound()); } var dto = new ItemDTO() { Item = _itemMapper.MapToItemDisplay(item), CategoriesForCreation = _bll.CategoryService.GetAllSubCategoriesAsync().Result.Select(c => _categoryMapper.Map(c)), BrandsForCreation = brands.Select(b => _brandMapper.Map(b)) }; return(Ok(dto)); }
public async Task<ActionResult<IEnumerable<Item>>> GetItems() { var items = await _bll.UserWishListService.GetUsersWishListAsync(User.UserGuidId()); var result = items.Select(i => _itemMapper.MapToItemDisplay(i)); return Ok(result); }
public async Task <ActionResult <IEnumerable <ItemDisplayView> > > IndexView(string?search = "") { var items = (await _bll.ItemService.AllAsync(search)); var itemsView = new ItemDisplayView() { Items = items.Select(i => _itemMapper.MapToItemDisplay(i)), Categories = _bll.CategoryService.GetAllSubCategoriesAsync().Result.Select(c => _categoryMapper.Map(c)), Brands = _bll.BrandService.AllAsync().Result.Select(b => _brandMapper.Map(b)) }; return(Ok(itemsView)); }
public async Task <ActionResult <IEnumerable <ItemDisplayView> > > IndexView(Guid?brandId) { var items = (await _bll.ItemService.AllAsync("", null, (brandId == null) ? null : new List <Guid> { (Guid)brandId })); var itemsView = new ItemDisplayView() { Items = items.Select(i => _itemMapper.MapToItemDisplay(i)), Categories = _bll.CategoryService.GetAllSubCategoriesAsync().Result.Select(c => _categoryMapper.Map(c)), Brands = _bll.BrandService.AllAsync().Result.Select(b => _brandMapper.Map(b)) }; return(Ok(itemsView)); }