public async Task <ActionResult> MyLeave() { //Find and get all resources var user = await _userManager.GetUserAsync(User); var leaveRequests = await _unitOfWork.LeaveReuqests.FindAll( request => request.RequestingEmployeeId == user.Id, includes : new List <string> { "LeaveType" } ); var leaveAllocations = await _unitOfWork.LeaveAllocations.FindAll(allocation => allocation.EmployeeId == user.Id); //Map all that needs mapping var mappedLeaveRequests = _mapper.Map <List <LeaveRequestViewModel> >(leaveRequests); var mappedLeaveAllocations = _mapper.Map <List <LeaveAllocationViewModel> >(leaveAllocations); //Create a model var model = new MyLeaveViewModel { LeaveAllocations = mappedLeaveAllocations, LeaveRequests = mappedLeaveRequests }; return(View(model)); }
public async Task <ActionResult> MyLeave() { var user = await _userManager.GetUserAsync(User); var userId = user.Id; var requests = await _leaverequestrepo.GetLeaveRequestsByEmployeeId(userId); var allocations = await _leaveallocationrepo.GetLeaveAllocationsByEmployee(userId); var leaveRequests = _mapper.Map <List <LeaveRequestViewModel> >(requests.ToList()); var leaveAllocations = _mapper.Map <List <LeaveAllocationViewModel> >(allocations.ToList()); var model = new MyLeaveViewModel { LeaveRequests = leaveRequests, LeaveAllocations = leaveAllocations }; return(View(model)); }