public ActionResult AddOrEdit(Complain emp) { try { using (InfraDbEntities db = new InfraDbEntities()) { if (emp.Id == 0) { db.Complains.Add(emp); db.SaveChanges(); } else { db.Entry(emp).State = EntityState.Modified; db.SaveChanges(); } ViewBag.RoomId = new SelectList(db.Classrooms, "CId", "CRoomNo", emp.RoomId); ViewBag.InfrustructureId = new SelectList(db.Infrustructures, "IId", "ITypes", emp.InfrustructureId); } return(Json(new { success = true, html = GlobalClass.RenderRazorViewToString(this, "ViewAll", GetAllComplain()), message = "Submitted Successfully" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public ActionResult AddOrEdit(Classroom croom) { try { using (InfraDbEntities db = new InfraDbEntities()) { if (croom.CId == 0) { db.Classrooms.Add(croom); db.SaveChanges(); } else { db.Entry(croom).State = EntityState.Modified; db.SaveChanges(); } } return(Json(new { success = true, html = GlobalClass.RenderRazorViewToString(this, "ViewAll", GetAllClassroom()), message = "Submitted Successfully" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet)); } }