Ejemplo n.º 1
0
        public IActionResult Update(long id, [FromBody] ShoppingListItem item)
        {
            if (item == null || item.Id != id)
            {
                return(BadRequest());
            }

            var shList = _context.ShoppingListItems.FirstOrDefault(t => t.Id == id);

            if (shList == null)
            {
                return(NotFound());
            }
            shList.ItemID   = item.ItemID;
            shList.ItemName = item.ItemName;
            shList.Price    = item.Price;

            _context.ShoppingListItems.Update(shList);
            _context.SaveChanges();
            return(new NoContentResult());
        }