示例#1
0
        // GET: Employee/Leave/Status
        public ActionResult Details()
        {
            try
            {
                var _leaveViewModel = new LeaveViewModel();
                _leaveViewModel.availedLeaveViewModel = new AvailedLeaveViewModel();
                _leaveViewModel.LeaveRequestInfo      = new LeaveRequestInfo();
                _leaveViewModel.CasualLeave           = new LeaveInfo();
                _leaveViewModel.AnnualLeave           = new LeaveInfo();

                var _leaveAllowed = new LeaveAllowedInfo();

                using (LeaveRequestRepository Repo = new LeaveRequestRepository())
                {
                    _leaveViewModel.CasualLeaveRequestInfoList = Repo.GetCasualLeaveRequestListByEmployeeId(CurrentUser.EmployeeInfoId);
                    _leaveViewModel.AnnualLeaveRequestInfoList = Repo.GetAnnualLeaveRequestListByEmployeeId(CurrentUser.EmployeeInfoId);

                    _leaveViewModel.LeaveRequestInfo = Repo.GetLeaveRequestLastRecordByEmployeeId(CurrentUser.EmployeeInfoId);

                    if (_leaveViewModel.LeaveRequestInfo == null)
                    {
                        _leaveViewModel.LeaveRequestInfo = new LeaveRequestInfo();
                    }

                    _leaveViewModel.availedLeaveViewModel.CasualLeaveRequestInfoList = _leaveViewModel.CasualLeaveRequestInfoList;
                    _leaveViewModel.availedLeaveViewModel.AnnualLeaveRequestInfoList = _leaveViewModel.AnnualLeaveRequestInfoList;
                }

                using (LeaveAllowedRepository Repo = new LeaveAllowedRepository())
                {
                    _leaveAllowed = Repo.GetLeaveAllowedByEmployeeId(CurrentUser.EmployeeInfoId);
                }

                _leaveViewModel.CasualLeave.Allowed   = _leaveAllowed.Casual;
                _leaveViewModel.CasualLeave.Availed   = LeavesCounter.GetAvailedLeaves(_leaveViewModel.CasualLeaveRequestInfoList);
                _leaveViewModel.CasualLeave.Remaining = _leaveViewModel.CasualLeave.Allowed - _leaveViewModel.CasualLeave.Availed;

                _leaveViewModel.AnnualLeave.Allowed   = _leaveAllowed.Annual;
                _leaveViewModel.AnnualLeave.Availed   = LeavesCounter.GetAvailedLeaves(_leaveViewModel.AnnualLeaveRequestInfoList);
                _leaveViewModel.AnnualLeave.Remaining = _leaveViewModel.AnnualLeave.Allowed - _leaveViewModel.AnnualLeave.Availed;

                if (_leaveViewModel.CasualLeave.Availed >= _leaveAllowed.Casual)
                {
                    _leaveViewModel.LeaveRequestInfo.IsCasualLeaveAvailed = true;
                }

                if (_leaveViewModel.AnnualLeave.Availed >= _leaveAllowed.Annual)
                {
                    _leaveViewModel.LeaveRequestInfo.IsAnnualLeaveAvailed = true;
                }

                return(View(_leaveViewModel));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Leave", "Details")));
            }
        }
示例#2
0
        // GET: Admin/Leave/Manage
        public ActionResult Manage(string id = "")
        {
            try
            {
                ViewBag.EmployeeId = GetEmployeeFullNameList();

                int empId;
                var _leaveViewModel = new LeaveViewModel();
                _leaveViewModel.LeaveRequestInfoList = new List <LeaveRequestInfo>();
                _leaveViewModel.LeaveRequestInfo     = new LeaveRequestInfo();
                _leaveViewModel.CasualLeave          = new LeaveInfo();
                _leaveViewModel.AnnualLeave          = new LeaveInfo();

                var _leaveAllowed = new LeaveAllowedInfo();

                if (!int.TryParse(id, out empId))
                {
                    _leaveViewModel = null;

                    return(View(_leaveViewModel));
                }

                using (LeaveRequestRepository Repo = new LeaveRequestRepository())
                {
                    _leaveViewModel.CasualLeaveRequestInfoList = Repo.GetCasualLeaveRequestListByEmployeeId(empId);
                    _leaveViewModel.AnnualLeaveRequestInfoList = Repo.GetAnnualLeaveRequestListByEmployeeId(empId);

                    _leaveViewModel.LeaveRequestInfoList = Repo.GetLeaveRequestListByEmployeeId(empId);
                    _leaveViewModel.LeaveRequestInfo     = Repo.GetLeaveRequestLastRecordByEmployeeId(empId);
                }

                using (LeaveAllowedRepository Repo = new LeaveAllowedRepository())
                {
                    _leaveAllowed = Repo.GetLeaveAllowedByEmployeeId(empId);
                }

                _leaveViewModel.CasualLeave.Allowed   = _leaveAllowed.Casual;
                _leaveViewModel.CasualLeave.Availed   = LeavesCounter.GetAvailedLeaves(_leaveViewModel.CasualLeaveRequestInfoList);
                _leaveViewModel.CasualLeave.Remaining = _leaveViewModel.CasualLeave.Allowed - _leaveViewModel.CasualLeave.Availed;

                _leaveViewModel.AnnualLeave.Allowed   = _leaveAllowed.Annual;
                _leaveViewModel.AnnualLeave.Availed   = LeavesCounter.GetAvailedLeaves(_leaveViewModel.AnnualLeaveRequestInfoList);
                _leaveViewModel.AnnualLeave.Remaining = _leaveViewModel.AnnualLeave.Allowed - _leaveViewModel.AnnualLeave.Availed;

                _leaveViewModel.EmployeeInfoId = id.ToString();

                return(View(_leaveViewModel));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Leave", "Manage")));
            }
        }