public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Address,Item")] Delivery delivery) { if (id != delivery.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(delivery); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DeliveryExists(delivery.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(delivery)); }
public async Task UpdateAsync(Seller obj) { bool hasAny = await _context.Seller.AnyAsync(x => x.Id == obj.Id); if (!hasAny) { throw new NotFoundException("Id not found"); } try { _context.Update(obj); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException e) { throw new DbConcurrencyException(e.Message); } }