예제 #1
0
        public static EventApproveViewModel GetById(int id)
        {
            EventApproveViewModel result = new EventApproveViewModel();

            using (var db = new MarComContext())
            {
                result = (from e in db.T_Event
                          join em in db.M_Employee
                          on e.Request_By equals em.Id
                          where e.Id == id
                          select new EventApproveViewModel
                {
                    Id = e.Id,
                    Code = e.Code,
                    Event_Name = e.Event_Name,
                    Place = e.Place,
                    Start_Date = e.Start_Date,
                    End_Date = e.End_Date,
                    Budget = e.Budget,
                    Request_By = e.Request_By,
                    NameRequest = em.First_Name + " " + em.Last_Name,
                    Request_Date = e.Request_Date,
                    Note = e.Note,
                    Status = e.Status
                }).FirstOrDefault();
            }
            return(result);
        }
예제 #2
0
        public ActionResult Approve(int id)
        {
            ViewBag.Employee = new SelectList(EventApproveRepo.GetEmp(), "Id", "Full_Name");
            EventApproveViewModel model = EventApproveRepo.GetById(id);

            return(PartialView("_Approve", model));
        }
예제 #3
0
        public static ResultResponse Approve(EventApproveViewModel entity)
        {
            ResultResponse result = new ResultResponse();

            try
            {
                using (var db = new MarComContext())
                {
                    T_Event ev = db.T_Event.Where(e => e.Id == entity.Id).FirstOrDefault();
                    if (ev != null)
                    {
                        ev.Reject_Reason = entity.Reject_Reason;
                        ev.Status        = entity.Status;
                        ev.Assign_To     = entity.Assign_To;

                        if (entity.Status == 2)
                        {
                            ev.Approved_Date = DateTime.Now;
                            ev.Approved_By   = entity.Approved_By;
                        }

                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = ex.Message;
            }
            return(result);
        }
예제 #4
0
        public ActionResult Approve(EventApproveViewModel model)
        {
            UserViewModel model3 = GetIdByName(User.Identity.Name);

            model.Approved_By = model3.M_Employee_Id;
            ResultResponse result = EventApproveRepo.Approve(model);

            return(Json(new
            {
                success = result.Success,
                entity = model,

                message = result.Message
            }, JsonRequestBehavior.AllowGet));
        }