public IHttpActionResult PatchProduct(int id, [FromUri] ProductPatchVM item) { Product product = db.Product.Find(id); if (product == null) { return(NotFound()); } product.ProductName = item.ProductName; product.Price = item.Price; db.SaveChanges(); return(Ok(product)); }
public IHttpActionResult PatchProduct(int id, [FromUri] ProductPatchVM product) { var item = db.Product.Find(id); if (item == null) { return(NotFound()); } if (product.Price.HasValue) { item.Price = product.Price.Value; } if (product.Stock.HasValue) { item.Stock = product.Stock.Value; } db.SaveChanges(); return(Ok(item)); }