public ActionResult Index() { var leaverequests = _leaveRequestRepo.FindAll(); var leaverequestmodel = _mapper.Map <List <LeaveRequestVM> >(leaverequests); var model = new AdminLeaveRequestVM { TotalRequests = leaverequestmodel.Count, ApprovedRequests = leaverequestmodel.Where(s => s.Approved == true).Count(), PendingRequests = leaverequestmodel.Where(s => s.Approved == null).Count(), RejectedRequests = leaverequestmodel.Where(s => s.Approved == false).Count(), LeaveRequests = leaverequestmodel }; return(View(model)); }
public async Task <ActionResult> Index() { var leaverequests = await _leaverequestrepo.FindAll(); var leaverequestModel = _mapper.Map <List <LeaveRequestVM> >(leaverequests); var model = new AdminLeaveRequestVM { TotalRequests = leaverequestModel.Count, ApprovedRequests = leaverequestModel.Count(q => q.Approved == true), PendingRequests = leaverequestModel.Count(q => q.Approved == null), RejectedRequests = leaverequestModel.Count(q => q.Approved == false), LeaveRequests = leaverequestModel }; return(View(model)); }
// GET: LeaveRequestController public async Task <ActionResult> Index() { //var leaveRequests =await _leaveRequestRepo.FindAll(); var leaveRequests = await _unitOfWork.LeaveRequests.FindAll(includes : new List <string> { "RequestingEmployee", "LeaveType" }); var leaveRequestsModel = _mapper.Map <List <LeaveRequestVM> >(leaveRequests); var model = new AdminLeaveRequestVM { TotalRequests = leaveRequestsModel.Count, ApprovedRequests = leaveRequestsModel.Count(q => q.Approved == true), PendingRequests = leaveRequestsModel.Count(q => q.Approved == null), RejectRequests = leaveRequestsModel.Count(q => q.Approved == false), LeaveRequests = leaveRequestsModel }; return(View(model)); }
// GET: LeaveRequestController public async Task <ActionResult> Index() { //var leaveRequests = _mapper.Map<List<LeaveRequestVM>>(await _leaveRequestRepository.FindAll()); List <string> includes = new List <string> { "RequestingEmployee" }; var leaveRequests = _mapper.Map <List <LeaveRequestVM> >(await _unitOfWork.LeaveRequests.FindAll(null, null, includes )); var model = new AdminLeaveRequestVM { TotalRequests = leaveRequests.Count, ApprovedRequests = leaveRequests.Count(q => q.Approved == true), LeaveRequestVMs = leaveRequests, PendingRequests = leaveRequests.Count(q => q.Approved == null), RejectedRequests = leaveRequests.Count(q => q.Approved == false), }; return(View(model)); }