public ActionResult ProcessRequest(int id) { LeaveRequest leaveRequest = db.LeaveRequests.Find(id); DepartmentManagerLeaveRequestViewModel viewModel = new DepartmentManagerLeaveRequestViewModel() { allDayEvent = leaveRequest.allDayEvent, departmentManager = leaveRequest.departmentManager, departmentManagerStatus = leaveRequest.departmentManagerStatus, employee = leaveRequest.employee, endTime = leaveRequest.endTime, description = leaveRequest.Description, leaveReason = leaveRequest.leaveReason, startTime = leaveRequest.startTime, departmentManagerComment = leaveRequest.departmentManagerComment, leaveRequestID = leaveRequest.leaveRequestID }; // ViewBag.possibleStatuses = new SelectList(db.RequestStatus, "requestStatusID", "requestStatusName",GetRequestStatusByName(leaveRequest.departmentManagerStatus.requestStatusName).requestStatusID); ViewBag.departmentManagerStatusID = new SelectList(db.RequestStatus, "requestStatusID", "requestStatusName", GetRequestStatusByName(leaveRequest.departmentManagerStatus.requestStatusName).requestStatusID); return View("DepartmentManagerProcessRequest", viewModel); }
// GET: DepartmentManagerLeaveRequestViewModels public ActionResult Index() { List<DepartmentManagerLeaveRequestViewModel> requstsList = new List<DepartmentManagerLeaveRequestViewModel>(); Employee emp = (Employee)Session["user"]; var m = from e in db.LeaveRequests where (e.deliveryManagerStatus.requestStatusName.Equals("Approved")) && e.departmentManagerStatus.requestStatusName.Equals("Pending") && (e.departmentManager.employeeID == emp.employeeID) select e; foreach (LeaveRequest req in m) { DepartmentManagerLeaveRequestViewModel viewModel = new DepartmentManagerLeaveRequestViewModel() { allDayEvent = req.allDayEvent, departmentManager = req.departmentManager, departmentManagerStatus = req.departmentManagerStatus, employee = req.employee, endTime = req.endTime, description = req.Description, leaveReason = req.leaveReason, startTime = req.startTime, departmentManagerComment = req.departmentManagerComment, leaveRequestID = req.leaveRequestID }; requstsList.Add(viewModel); } return View(requstsList.AsQueryable()); }