Пример #1
0
        public ActionResult AddRequest(Request request)
        {
            if (Session["UserID"] != null)
            {
                if (ModelState.IsValid)
                {
                    request.EmpId       = Convert.ToInt32(Session["UserID"]);
                    request.RequestDate = DateTime.Now;
                    request.State       = 1;
                    if (request.Loan != null)
                    {
                        request.Type = "Loan";
                    }
                    else if (request.Start != null && request.End != null)
                    {
                        request.Type = "Vacation";
                    }
                    else
                    {
                        request.Type = "Open Request";
                    }
                    db.Request.Add(request);
                    db.SaveChanges();

                    return(RedirectToAction("SubmittedRequest"));
                }
                return(View(request));
            }
            else
            {
                return(RedirectToAction("../Login/Index"));
            }
        }
Пример #2
0
        public ActionResult Create([Bind(Include = "Id,EmpId,RequestDate,Loan,Start,End,Desc,Type,State")] Request request)
        {
            if (ModelState.IsValid)
            {
                db.Request.Add(request);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.EmpId = new SelectList(db.User, "Id", "Name", request.EmpId);
            return(View(request));
        }
Пример #3
0
 public ActionResult DeleteConfirm(int?id)
 {
     if (Session["UserID"] != null)
     {
         User user = db.User.Find(id);
         db.User.Remove(user);
         db.SaveChanges();
         return(RedirectToAction("List"));
     }
     else
     {
         return(RedirectToAction("../Login/Index"));
     }
 }
Пример #4
0
        public JsonResult SaveEvent(Events e)
        {
            var status = false;

            using (afandemEntities6 dc = new afandemEntities6())
            {
                if (e.EventID > 0)
                {
                    //Update the event
                    var v = dc.Events.Where(a => a.EventID == e.EventID).FirstOrDefault();
                    if (v != null)
                    {
                        v.Subject     = e.Subject;
                        v.Start       = e.Start;
                        v.End         = e.End;
                        v.Description = e.Description;
                        v.IsFullDay   = e.IsFullDay;
                        v.ThemeColor  = e.ThemeColor;
                    }
                }
                else
                {
                    dc.Events.Add(e);
                }

                dc.SaveChanges();
                status = true;
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Пример #5
0
        public JsonResult DeleteEvent(int eventID)
        {
            var status = false;

            using (afandemEntities6 dc = new afandemEntities6())
            {
                var v = dc.Events.Where(a => a.EventID == eventID).FirstOrDefault();
                if (v != null)
                {
                    dc.Events.Remove(v);
                    dc.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Пример #6
0
 public ActionResult Profile(User user)
 {
     if (Session["UserID"] != null)
     {
         if (ModelState.IsValid)
         {
             user.Type            = Convert.ToInt32(Session["UserType"]);
             db.Entry(user).State = EntityState.Modified;
             db.SaveChanges();
             Session["UserName"] = user.Name;
             return(RedirectToAction("Profile"));
         }
         return(View(user));
     }
     else
     {
         return(RedirectToAction("../Login/Index"));
     }
 }