public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Cpf,Rg,Tel,Cel,Email,Address")] Owner owner) { if (id != owner.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(owner); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OwnersExists(owner.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(owner)); }
public async Task UpdateAsync(Tenant obj) { bool hasAny = await _context.Tenant.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); } }