public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,DataNascimento,Raca,Sexo,Origem")] Rebanho rebanho) { if (id != rebanho.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(rebanho); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RebanhoExists(rebanho.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(rebanho)); }
public async Task <IActionResult> Create([Bind("Id,Nome,DataNascimento,Raca,Sexo,Origem")] Rebanho rebanho) { if (ModelState.IsValid) { _context.Add(rebanho); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(rebanho)); }