public Task <CreateDependentResponse> Handle(CreateDependentRequest request, CancellationToken cancellationToken) { var dependent = Mapper.Map <Dependent>(request); var employee = _context.Employees.SingleOrDefault(e => e.Id == dependent.EmployeeId); if (employee == null) { return(Task.FromResult <CreateDependentResponse>(null)); } if (employee.Dependents == null) { employee.Dependents = new List <Dependent>(); } employee.Dependents.Add(dependent); var calculator = new BenefitsCalculator.BenefitsCalculator(); calculator.CalculateBenefitsCostsFor(employee); _context.SaveChanges(); return(CreateResponse(dependent, employee)); }
public Task <EmployeeResponse> Handle(CreateEmployeeRequest request, CancellationToken cancellationToken) { var employee = Mapper.Map <Employee>(request); var calculator = new BenefitsCalculator.BenefitsCalculator(); calculator.CalculateBenefitsCostsFor(employee); _context.Employees.Add(employee); _context.SaveChanges(); var response = Mapper.Map <EmployeeResponse>(employee); return(Task.FromResult(response)); }
public BenefitsCalculatorTests() { _calculator = new BenefitsCalculator(); }