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,Name,Phone,GenderId,CityId,RegionId,LastPurchase,ClassificationId,UserId")] Customer customer) { if (id != customer.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(customer); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(customer.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(customer)); }
public async Task UpdateAsync(Seller obj) { //se existe algum any dado no bd bool hasAny = await _context.Seller.AnyAsync(x => x.Id == obj.Id); if (!hasAny) { throw new NotFoundException("Sorry,Seller Id not found!"); } try { _context.Update(obj); await _context.SaveChangesAsync(); }catch (DbUpdateConcurrencyException e) { throw new DbConcurrencyException(e.Message); } }
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 (DbConcurrencyException e) { throw new DbConcurrencyException(e.Message); } }
/// <summary> /// Update seller /// </summary> /// <param name="seller">Seller</param> public async Task UpdateAsync(Seller seller) { bool has = await _context.Seller.AnyAsync(s => s.Id == seller.Id); if (!has) { throw new NotFoundException($"Seller not found!"); } try { _context.Update(seller); await _context.SaveChangesAsync(); } catch (DbConcurrencyException ex) { throw new DbConcurrencyException(ex.Message); } }
public async Task UpdateAsync(Seller slr) { bool hasAny = await _context.Seller.AnyAsync(x => x.Id == slr.Id); if (!hasAny) { throw new NotFoundException("Seller: " + slr.Name + " Id: " + slr.Id + " was not found in database!"); } try { _context.Update(slr); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException ex) { string msg = ex.Message; if (ex.InnerException != null) { msg = ""; msg = ex.Message + "\n" + ex.InnerException.Message; } throw new DbConcurrencyException(msg); } }