public Employee Post(EmployeeDTO employeeDto) { //todo: DI can remove all visitor from here var deductionVisitor = new DeductionVisitor(); var discountVisitor = new DiscountVisitor(); var employee = new Employee { Name = employeeDto.Name, Dependents = employeeDto.Dependents }; employee.Accept(deductionVisitor); employee.Accept(discountVisitor); return(employee); }
public VisitorViewModel() { var employee = new Employee(); employee.Savings.Add(new Salary { Amount = 50000 }); employee.Savings.Add(new HomeRent { RentAmount = 15000 }); employee.Savings.Add(new CreditCardBill { Bill = 20000 }); var savingsVisitor = new SavingVisitor(); employee.Accept(savingsVisitor); this.Savings = Convert.ToString(savingsVisitor.Balance); }
private Payroll ClosePayroll(Employee employee, List <LiquidationDocument> liquidation) { liquidation.OfType <Absency>().ToList().ForEach(absency => absency.Amount = -employee.DailySalary()); liquidation.Add(new Salary { Amount = employee.Salary, Employee = employee, EmployeeId = employee.Id }); var payroll = new Payroll() { Employee = employee, EmployeeId = employee.Id, PreviousBalance = employee.Balance, Liquidation = liquidation, Balance = employee.Balance + liquidation.Select(x => x.Amount).DefaultIfEmpty(0).Sum() }; employee.Accept(payroll); _payrollRepository.Add(payroll); return(payroll); }