public async Task <IActionResult> Edit(int id, [Bind("Id,Name,BornDate,RegistryDate")] Person person) { if (id != person.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(person); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PersonExists(person.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(person)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,DocumentType,Name,Number,Validity,DocumentLocale")] Document document) { if (id != document.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(document); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DocumentExists(document.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(document)); }
public async Task UpdateAsync(City obj) { bool hasAny = await _context.Citys.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); } }