public Decimal GetTotalCost(Int32 id) { IPayrollRepository repo = GetRepository(); Decimal cost = 0; Employee employee = repo.GetEmployeeById(id); if (employee != null) { BenefitCalculator calc = new BenefitCalculator(employee.BenefitPlan, employee.PayCycle, new NameDiscount()); cost = calc.CalculatePayPeriodCost(employee); foreach (Dependent dependent in employee.Dependents) { cost += calc.CalculatePayPeriodCost(dependent); } } return(cost); }
public Decimal GetDependentCost(Int32 id) { IPayrollRepository repo = GetRepository(); Decimal cost = 0; Dependent dependent = repo.GetDependentById(id); if (dependent != null) { BenefitCalculator calc = new BenefitCalculator(dependent.Employee.BenefitPlan, dependent.Employee.PayCycle, new NameDiscount()); cost = calc.CalculatePayPeriodCost(dependent); } return(cost); }