public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] TipoContato tipoContato) { if (id != tipoContato.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tipoContato); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TipoContatoExists(tipoContato.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tipoContato)); }
public async Task Update(Contatos contatos) { if (!await _context.Contatos.AnyAsync(x => x.Id == contatos.Id)) { throw new NotFoundException("Id not found"); } try { _context.Update(contatos); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException e) { throw new DbConcurrencyException(e.Message); } }