public ActionResult AddOrEdit(int id = 0) { Infrustructure emp = new Infrustructure(); if (id != 0) { using (InfraDbEntities db = new InfraDbEntities()) { emp = db.Infrustructures.Where(x => x.IId == id).FirstOrDefault <Infrustructure>(); } } return(View(emp)); }
public ActionResult Delete(int id) { try { using (InfraDbEntities db = new InfraDbEntities()) { Infrustructure inf = db.Infrustructures.Where(x => x.IId == id).FirstOrDefault <Infrustructure>(); db.Infrustructures.Remove(inf); db.SaveChanges(); } return(Json(new { success = true, html = GlobalClass.RenderRazorViewToString(this, "ViewAll", GetAllInfrustructure()), message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public ActionResult AddOrEdit(int id = 0) { Complain emp = new Complain(); Infrustructure infra = new Infrustructure(); Classroom croom = new Classroom(); ViewBag.infraId = infra.IId; ViewBag.infraType = infra.ITypes; if (id != 0) { using (InfraDbEntities db = new InfraDbEntities()) { emp = db.Complains.Where(x => x.Id == id).FirstOrDefault <Complain>(); } } ViewBag.RoomId = new SelectList(db.Classrooms, "CId", "CRoomNo", emp.RoomId); ViewBag.InfrustructureId = new SelectList(db.Infrustructures, "IId", "ITypes", emp.InfrustructureId); return(View(emp)); }
public ActionResult AddOrEdit(Infrustructure inf) { try { using (InfraDbEntities db = new InfraDbEntities()) { if (inf.IId == 0) { db.Infrustructures.Add(inf); db.SaveChanges(); } else { db.Entry(inf).State = EntityState.Modified; db.SaveChanges(); } } return(Json(new { success = true, html = GlobalClass.RenderRazorViewToString(this, "ViewAll", GetAllInfrustructure()), message = "Submitted Successfully" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet)); } }