示例#1
0
        public ActionResult MyLeave()
        {
            try
            {
                var employee = _userManager.GetUserAsync(User).Result;

                var allocations   = _mapper.Map <List <LeaveAllocationViewModel> >(_leaveAllocationRepo.GetLeaveAllocationsByEmployeeId(employee.Id, DateTime.Now.Year));
                var leaveRequests = _mapper.Map <List <LeaveRequestViewModel> >(_repo.GetLeaveRequestsByEmployeeId(employee.Id));

                var model = new EmployeeLeaveRequestViewModel
                {
                    LeaveAllocations = allocations,
                    LeaveRequests    = leaveRequests
                };

                return(View(model));
            }
            catch
            {
                return(RedirectToAction(nameof(Index), "Home"));
            }
        }