public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Department department) { if (id != department.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(department); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DepartmentExists(department.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(department)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,CompanyName,ContactName,ContactTitle,City,Country,Phone,Fax")] Supplier supplier) { if (id != supplier.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(supplier); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SupplierExists(supplier.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(supplier)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Date,Amount,Status")] SalesRecord salesRecord) { if (id != salesRecord.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(salesRecord); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SalesRecordExists(salesRecord.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(salesRecord)); }
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); } }
public async Task UpdateAsync(Seller obj) { // Any -> verificar se existe algum vendedor com om aquele ID if (!await _context.Seller.AnyAsync(x => x.Id == obj.Id)) { throw new NotFoundException("Id não encontrado"); } try { _context.Update(obj); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException e) { throw new DbConcurrencyException(e.Message); } }
public async Task UpdateAsync(Seller s) { bool hasAny = await _context.Seller.AnyAsync(sl => sl.Id == s.Id); if (!hasAny) { throw new NotFoundException("Seller Id not found"); } try { _context.Update(s); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException e) { throw new DbConcurrencyException(e.Message); } }
public async Task UpdateAsync(Seller seller) { bool sellerExists = await _context.Seller.AnyAsync(_seller => _seller.Id == seller.Id); if (!sellerExists) { throw new NotFoundException("Id not found"); } try { _context.Update(seller); await _context.SaveChangesAsync(); } catch (DbConcurrencyException exception) { throw new DbConcurrencyException(exception.Message); } }
public async Task UpdateAsync(Seller seller) { bool hasAny = await _context.Seller.AnyAsync(s => s.Id == seller.Id); if (hasAny) { try { _context.Update(seller); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException ex) { throw new DBConcurrencyException(ex.Message); } } else { throw new NotFoundException("Seller not found by id"); } }