public async Task <IActionResult> PutPackages(int id, Packages packages) { if (id != packages.PackageId) { return(BadRequest()); } _context.Entry(packages).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PackagesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutSuppliers(int id, Suppliers suppliers) { if (id != suppliers.SupplierId) { return(BadRequest()); } _context.Entry(suppliers).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SuppliersExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private void HandleConcurrencyError(DbUpdateConcurrencyException ex) { ex.Entries.Single().Reload(); var state = context.Entry(selectedSupplier).State; if (state == EntityState.Detached) { MessageBox.Show("Another user has deleted that Supplier.", "Concurrency Error"); } else { string message = "Another user has updated that Supplier.\n" + "The current database values will be displayed."; MessageBox.Show(message, "Concurrency Error"); } this.DisplayLVSuppliers(); }