コード例 #1
0
        // GET: LeaveRequestController1
        public ActionResult Index()
        {
            var leaverequests = _LeaveRequestRepo.Findall();

            var leaverequestsModel = _mapper.Map <List <LeaveRequestVM> >(leaverequests);
            var model = new AdminiLeaveRequestsViewVM
            {
                TotalRequests = leaverequestsModel.Count(),
                //ApprovedRequests = leaverequestsModel.Where(q=> q.Approved == true).Count(), //One or the other !!!
                ApprovedRequests = leaverequestsModel.Count(q => q.Approved == true),
                PendingRequests  = leaverequestsModel.Count(q => q.Approved == null),
                RejectedRequests = leaverequestsModel.Count(q => q.Approved == false),
                LeaveRequests    = leaverequestsModel
            };

            return(View(model));
        }