public ActionResult Create(DepartamentoOpet departamentoOpet) { _context.DepartamentosOpet.Add(departamentoOpet); _context.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(DepartamentoOpet departamentoOpet) { if (ModelState.IsValid) { _context.Entry(departamentoOpet).State = EntityState.Modified; _context.SaveChanges(); return(RedirectToAction("Index")); } return(View(departamentoOpet)); }
public ActionResult Delete(long id) { try { DepartamentoOpet departamentoOpet = _context.DepartamentosOpet.Find(id); _context.DepartamentosOpet.Remove(departamentoOpet); _context.SaveChanges(); TempData["Message"] = "Departamento " + departamentoOpet.Nome.ToUpper() + " foi removido"; return(RedirectToAction("Index")); } catch { return(View()); } }