public async Task <IActionResult> PutEquipamento(int id, Equipamento equipamento) { if (id != equipamento.Id) { return(BadRequest()); } _context.Entry(equipamento).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EquipamentoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("Nome,Sexo,Data,Cidade,Contato")] Dados dados) { try { if (ModelState.IsValid) { _context.Add(dados); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } catch (DbUpdateException /* ex */) { ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."); } return(View(dados)); }