예제 #1
0
        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));
        }
예제 #2
0
 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));
     }
 }
예제 #3
0
        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));
        }
예제 #4
0
 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));
     }
 }