public async Task <IActionResult> PutSupplier(int id, Supplier supplier) { if (id != supplier.Id) { return(BadRequest()); } _context.Entry(supplier).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SupplierCheck(id)) { return(NotFound()); } else { _logger.LogError("PUT Supplier Failed to save changes"); throw; } } return(NoContent()); }
public async Task <IActionResult> PutProduct(int id, Product product) { if (id != product.Id) { return(BadRequest()); } _context.Entry(product).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductCheck(id)) { return(NotFound()); } else { _logger.LogError("PUT Product Failed to save changes"); throw; } } return(NoContent()); }