Exemple #1
0
        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));
            }
        }
Exemple #2
0
        public ActionResult Create([Bind(Include = "Id,Title,InfrustructureId,Description,StudentId,RoomId,ComplainDate,ComplainStatus")] Complain complain)
        {
            if (ModelState.IsValid)
            {
                db.Complains.Add(complain);
                db.SaveChanges();
                return(RedirectToAction("Create"));
            }

            ViewBag.RoomId           = new SelectList(db.Classrooms, "CId", "CRoomNo", complain.RoomId);
            ViewBag.InfrustructureId = new SelectList(db.Infrustructures, "IId", "ITypes", complain.InfrustructureId);
            return(View(complain));
        }
 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));
     }
 }
Exemple #4
0
 public ActionResult Delete(int id)
 {
     try
     {
         using (InfraDbEntities db = new InfraDbEntities())
         {
             Complain emp = db.Complains.Where(x => x.Id == id).FirstOrDefault <Complain>();
             db.Complains.Remove(emp);
             db.SaveChanges();
         }
         return(Json(new { success = true, html = GlobalClass.RenderRazorViewToString(this, "ViewAll", GetAllComplain()), message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }