public List <VMLeaveQuotaChild> GetIndex(int FinancialYearID, VMLoggedUser LoggedInUser) { List <VMLeaveQuotaChild> vmLeaveQuotaChildList = new List <VMLeaveQuotaChild>(); List <VHR_EmployeeProfile> employees = DDService.GetEmployeeInfo(LoggedInUser); // Get All Employees from database Expression <Func <LeaveQuotaYear, bool> > SpecificEntries = c => c.FinancialYearID == FinancialYearID; List <LeaveQuotaYear> leaveQuotaYearList = LeaveQuotaYearReporsitory.FindBy(SpecificEntries); // Get all Leave quota Balances for specific financial year foreach (var item in employees) { if (leaveQuotaYearList.Where(aa => aa.EmployeeID == item.PEmployeeID).Count() > 0) { VMLeaveQuotaChild vmLeaveQuotaChild = new VMLeaveQuotaChild(); vmLeaveQuotaChild.EmpID = item.PEmployeeID; vmLeaveQuotaChild.EmpNo = item.OEmpID; vmLeaveQuotaChild.EmployeeName = item.EmployeeName; vmLeaveQuotaChild.AL = GetRemainingLeaveBalance(leaveQuotaYearList.Where(aa => aa.EmployeeID == item.PEmployeeID && aa.LeaveTypeID == 1).ToList()); vmLeaveQuotaChild.CL = GetRemainingLeaveBalance(leaveQuotaYearList.Where(aa => aa.EmployeeID == item.PEmployeeID && aa.LeaveTypeID == 2).ToList()); vmLeaveQuotaChild.SL = GetRemainingLeaveBalance(leaveQuotaYearList.Where(aa => aa.EmployeeID == item.PEmployeeID && aa.LeaveTypeID == 3).ToList()); vmLeaveQuotaChild.STDL = GetRemainingLeaveBalance(leaveQuotaYearList.Where(aa => aa.EmployeeID == item.PEmployeeID && aa.LeaveTypeID == 4).ToList()); vmLeaveQuotaChild.ACCL = GetRemainingACCLeaveBalance(leaveQuotaYearList.Where(aa => aa.EmployeeID == item.PEmployeeID && aa.LeaveTypeID == 1).ToList()); vmLeaveQuotaChild.JobTitleName = item.JobTitleName; vmLeaveQuotaChildList.Add(vmLeaveQuotaChild); } } return(vmLeaveQuotaChildList); }
public ActionResult Create4(VMLeaveQuota vmLeaveQuota, int?[] SelectedEmpIds) { List <VMLeaveQuotaChild> vmLeaveQuotaChildEntries = new List <VMLeaveQuotaChild>(); foreach (var empID in SelectedEmpIds) { VMLeaveQuotaChild vmLeaveQuotaChild = new VMLeaveQuotaChild(); string AL = Request.Form["AL-" + empID.Value.ToString()].ToString(); string CL = Request.Form["CL-" + empID.Value.ToString()].ToString(); string SL = Request.Form["SL-" + empID.Value.ToString()].ToString(); string STDL = Request.Form["STDL-" + empID.Value.ToString()].ToString(); string ALCop = Request.Form["ALCop-" + empID.Value.ToString()].ToString(); string ALCF = Request.Form["ALCF-" + empID.Value.ToString()].ToString(); vmLeaveQuotaChild.EmpID = (int)empID; vmLeaveQuotaChild.AL = (float)Convert.ToDouble(AL); vmLeaveQuotaChild.CL = (float)Convert.ToDouble(CL); vmLeaveQuotaChild.SL = (float)Convert.ToDouble(SL); vmLeaveQuotaChild.STDL = (float)Convert.ToDouble(STDL); vmLeaveQuotaChild.CollapseLeave = (float)Convert.ToDouble(ALCop); vmLeaveQuotaChild.CarryForward = (float)Convert.ToDouble(ALCF); vmLeaveQuotaChildEntries.Add(vmLeaveQuotaChild); } vmLeaveQuota.LeaveQuotaChild = vmLeaveQuotaChildEntries.ToList(); VMLeaveQuota vm = LeaveQuotaService.GetCreate4(vmLeaveQuota); if (vm.ErrorMessages.Count == 0) { return(RedirectToAction("Index")); } else { return(View("Create3", vm)); } }
public VMLeaveQuota GetCreate3(VMLeaveQuotaSelection es, int?[] SelectedEmployeeIds, VMLeaveQuota vmLeaveQuota) { List <VMLeaveQuotaChild> vmLeaveQuotaChildList = new List <VMLeaveQuotaChild>(); List <VHR_EmployeeProfile> employees = DDService.GetEmployeeInfo(); // Get All Employees from database List <LeavePolicy> leavePolicyList = DDService.GetLeavePolicy(); // Get all leave policies FinancialYear financialYear = DDService.GetFinancialYear().First(aa => aa.PFinancialYearID == es.FinancialYearID); // Get selected financial year List <FinancialYear> financialYearCloseList = DDService.GetFinancialYear().Where(aa => aa.FYStatus == false).OrderByDescending(aa => aa.FYEndDate).ToList(); List <LeaveQuotaYear> leaveQuotaPreviousYearList = new List <LeaveQuotaYear>(); // Get Old Financial Year if (financialYearCloseList.Count > 0) { int LastFinYearID = financialYearCloseList.FirstOrDefault().PFinancialYearID; Expression <Func <LeaveQuotaYear, bool> > SpecificEntries = c => c.FinancialYearID == LastFinYearID && c.LeaveTypeID == 1; leaveQuotaPreviousYearList = LeaveQuotaYearReporsitory.FindBy(SpecificEntries);// Get all Leave quota Balances for specific financial year } Expression <Func <LeaveQuotaYear, bool> > SpecificEntries2 = c => c.FinancialYearID == es.FinancialYearID; List <LeaveQuotaYear> leaveQuotaYearList = LeaveQuotaYearReporsitory.FindBy(SpecificEntries2);// Get all Leave quota Balances for specific financial year foreach (int empid in SelectedEmployeeIds) { if (leaveQuotaYearList.Where(aa => aa.EmployeeID == empid).Count() == 0) { VMLeaveQuotaChild vmLeaveQuotaChild = new VMLeaveQuotaChild(); VHR_EmployeeProfile employee = employees.First(aa => aa.PEmployeeID == empid);// Get Specific Employee float ALDays = GetTotalDays(leavePolicyList.Where(aa => aa.PLeavePolicyID == employee.ALPolicyID).ToList(), employee, financialYear); float CLDays = GetTotalDays(leavePolicyList.Where(aa => aa.PLeavePolicyID == employee.CLPolicyID).ToList(), employee, financialYear); float SLDays = GetTotalDays(leavePolicyList.Where(aa => aa.PLeavePolicyID == employee.SLPolicyID).ToList(), employee, financialYear); float STDLDays = GetTotalDays(leavePolicyList.Where(aa => aa.PLeavePolicyID == employee.STDLPolicyID).ToList(), employee, financialYear); vmLeaveQuotaChild.EmpID = employee.PEmployeeID; vmLeaveQuotaChild.EmpNo = employee.OEmpID; vmLeaveQuotaChild.EmployeeName = employee.EmployeeName; vmLeaveQuotaChild.JobTitleName = employee.JobTitleName; vmLeaveQuotaChild.FinancialYearID = financialYear.PFinancialYearID; vmLeaveQuotaChild.FinancialYearName = financialYear.FYName; if (employee.DOJ != null) { vmLeaveQuotaChild.DOJ = employee.DOJ.Value.ToString("dd-MMM-yyyy"); } vmLeaveQuotaChild.AL = ALDays; vmLeaveQuotaChild.CL = CLDays; vmLeaveQuotaChild.SL = SLDays; vmLeaveQuotaChild.STDL = STDLDays; // Get LeaveBalance for Previous Year if (leaveQuotaPreviousYearList.Where(aa => aa.EmployeeID == employee.PEmployeeID).Count() > 0) { vmLeaveQuotaChild.CollapseLeave = 0; vmLeaveQuotaChild.ALBalance = GetALLeaveBalance(leaveQuotaPreviousYearList.Where(aa => aa.EmployeeID == employee.PEmployeeID).ToList()); vmLeaveQuotaChild.CarryForward = vmLeaveQuotaChild.ALBalance - vmLeaveQuotaChild.CollapseLeave; } else { vmLeaveQuotaChild.CarryForward = 0; vmLeaveQuotaChild.CollapseLeave = 0; vmLeaveQuotaChild.ALBalance = 0; } vmLeaveQuotaChildList.Add(vmLeaveQuotaChild); } } vmLeaveQuota.FinancialYearID = financialYear.PFinancialYearID; vmLeaveQuota.FinancialYearName = financialYear.FYName; vmLeaveQuota.LeaveQuotaChild = vmLeaveQuotaChildList; return(vmLeaveQuota); }