public async Task <ActionResult <ProductCatalogue> > DeleteProductCatalogueItem(long id) { var ProductCatalogueItem = await _context.ProductCatalogue.FindAsync(id); if (ProductCatalogueItem == null) { return(NotFound()); } _context.ProductCatalogue.Remove(ProductCatalogueItem); await _context.SaveChangesAsync(); return(ProductCatalogueItem); }
public async Task <Product> UpdateProduct(int id, Product product) { try { // Below updates every property regardless of whether the values have changed _context.Products.Update(product); await _context.SaveChangesAsync(); } catch (Exception e) { throw; } return(product); }