public ActionResult Delete(PlanoConta model) { try { model = contexto.PlanosConta.Find(model.Id); int id = model.Centro.Id; contexto.PlanosConta.Remove(model); contexto.SaveChanges(); return RedirectToAction("Index", new { id = id }); } catch { return View(); } }
public ActionResult Edit(PlanoConta model) { try { if (ModelState.IsValid) { int id = ContaSession.InstituicaoDaConta().Id; contexto.Entry(model).State = System.Data.EntityState.Modified; contexto.SaveChanges(); return RedirectToAction("Index", new { id = id }); } return View(model); } catch { return View(model); } }
public ActionResult Create(PlanoConta model) { try { if (ModelState.IsValid) { int id_entidade = ContaSession.InstituicaoDaConta().Id; model.Centro = contexto.Centros.Find(id_entidade); contexto.PlanosConta.Add(model); contexto.SaveChanges(); return RedirectToAction("Index", new { id = id_entidade }); } return View(model); } catch { return View(model); } }