Example #1
0
        public async Task <IActionResult> PutItem(int listId, int itemId, [FromBody] Item item)
        {
            var wishList = await _wishListBusiness.Query().Include(w => w.Items).FirstOrDefaultAsync(w => w.Id == listId);

            if (wishList == null)
            {
                return(NotFound());
            }

            if (wishList.Items.FirstOrDefault(i => i.Id == itemId) == null)
            {
                return(BadRequest(@"List does not contains Item with id {itemId}"));
            }

            if (await _itemBusiness.GetAsync(itemId) == null)
            {
                return(NotFound());
            }

            item.Id = itemId;

            await _itemBusiness.UpdateAsync(item);

            return(NoContent());
        }