public ActionResult AdicionarEditar(int id = 0) { RegistroDisputa registroDisputa = new RegistroDisputa(); if (id != 0) { using (FormulaIFSContext db = new FormulaIFSContext()) { registroDisputa = db.RegistroDisputa.Where(x => x.Id == id).FirstOrDefault <RegistroDisputa>(); } } return(View(registroDisputa)); }
public ActionResult Delete(int id) { try { using (FormulaIFSContext db = new FormulaIFSContext()) { RegistroDisputa emp = db.RegistroDisputa.Where(x => x.Id == id).FirstOrDefault <RegistroDisputa>(); db.RegistroDisputa.Remove(emp); db.SaveChanges(); } return(Json(new { success = true, html = GlobalClass.RenderRazorViewToString(this, "Visao", GetRegistroDisputas()), message = "Deletado com sucesso" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public ActionResult AdicionarEditar(RegistroDisputa emp) { try { using (FormulaIFSContext db = new FormulaIFSContext()) { if (emp.Id == 0) { db.RegistroDisputa.Add(emp); db.SaveChanges(); } else { db.Entry(emp).State = EntityState.Modified; db.SaveChanges(); } } return(Json(new { success = true, html = GlobalClass.RenderRazorViewToString(this, "Visao", GetRegistroDisputas()), message = "Salvo com Sucesso" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet)); } }