public SalaryEmployee CreateObject(SalaryEmployee salaryEmployee, IEmployeeService _employeeService, ISalaryEmployeeDetailService _salaryEmployeeDetailService, ISalaryItemService _salaryItemService, ISalaryStandardDetailService _salaryStandardDetailService) { salaryEmployee.Errors = new Dictionary <String, String>(); if (_validator.ValidCreateObject(salaryEmployee, _employeeService, this)) { SalaryEmployee activesalaryEmployee = GetActiveObject(); // Activate yg baru if (activesalaryEmployee == null || (salaryEmployee.EffectiveDate > activesalaryEmployee.EffectiveDate && salaryEmployee.EffectiveDate <= DateTime.Now)) { salaryEmployee.IsActive = true; } _repository.CreateObject(salaryEmployee); // Deactivate yg lama if (activesalaryEmployee != null && salaryEmployee.IsActive) { activesalaryEmployee.IsActive = false; _repository.UpdateObject(activesalaryEmployee); } if (!salaryEmployee.Errors.Any()) { Employee employee = _employeeService.GetObjectById(salaryEmployee.EmployeeId); IList <SalaryStandardDetail> details = _salaryStandardDetailService.GetObjectsByTitleInfoId(employee.TitleInfoId); foreach (var detail in details) { SalaryEmployeeDetail sed = new SalaryEmployeeDetail { SalaryEmployeeId = salaryEmployee.Id, SalaryItemId = detail.SalaryItemId, Amount = detail.Amount, }; _salaryEmployeeDetailService.CreateObject(sed, this, _salaryItemService); } ; } } return(salaryEmployee); }