/// <summary> /// build employee information give the employee and its dependents /// </summary> /// <param name="inEmployeeInfo"></param> /// <returns></returns> public static List <EmployeeInformation> GetListOfEmployee(DataSet inEmployeeInfo) { List <EmployeeInformation> lstOfEmployee = new List <EmployeeInformation>(); List <EmployeeDTO> employee = new List <EmployeeDTO>(); List <DependentDTO> dependent = new List <DependentDTO>(); foreach (DataRow row in inEmployeeInfo.Tables[0].Rows) { EmployeeDTO record = new EmployeeDTO(row); employee.Add(record); } foreach (DataRow row in inEmployeeInfo.Tables[1].Rows) { DependentDTO record = new DependentDTO(row); dependent.Add(record); } foreach (EmployeeDTO emp in employee) { EmployeeInformation employeeInfo = new EmployeeInformation(); employeeInfo.Employee = emp; if (dependent.Exists(x => x.EmployeeID == emp.EmployeeID)) { List <DependentDTO> dependentPerEmployee = dependent.FindAll(x => x.EmployeeID == emp.EmployeeID); employeeInfo.Dependents = dependentPerEmployee; } lstOfEmployee.Add(employeeInfo); } return(lstOfEmployee); }
/// <summary> /// clalulates cost of benefit for each dependent /// </summary> /// <param name="dependent"></param> /// <returns></returns> private DependentBenefitCostInformation CalculateDependentBenefitCost(DependentDTO dependent) { DependentBenefitCostInformation dependentsInfo = new DependentBenefitCostInformation(); dependentsInfo.FullName = string.Concat(dependent.FirstName + " " + dependent.LastName); dependentsInfo.CostOfBenefit = Utility.RoundUpDecimal((decimal)(dependent.CostOfBenefitAnnual / 26)); if (DoesQualifyForDiscount(dependent.FirstName)) { dependentsInfo.CostOfBenefit = ApplyDiscountPerPayCheck((decimal)dependent.PercentageOfDiscount, (decimal)dependent.CostOfBenefitAnnual); } return(dependentsInfo); }