Exemplo n.º 1
0
 public long CreateEmployee(EmployeeInput input)
 {
     return(doInTransaction(
                () => {
         var departments = departmentRepository.FindByIds(new List <long> {
             input.DepartmentId
         });
         if (departments.Count == 0)
         {
             throw BusinessException.IllegalDepartmentId(input.DepartmentId);
         }
         if (input.SupervisorId != null)
         {
             var supervisors = employeeRepository.FindByIds(new List <long> {
                 input.SupervisorId ?? 0
             });
             if (supervisors.Count == 0)
             {
                 throw BusinessException.IllegalSupervisorId(input.SupervisorId ?? 0);
             }
         }
         return employeeRepository.Insert(input);
     }
                ));
 }
Exemplo n.º 2
0
 public bool ModifyEmployee(long id, EmployeeInput input)
 {
     return(doInTransaction(
                () => {
         var departments = departmentRepository.FindByIds(new List <long> {
             input.DepartmentId
         });
         if (departments.Count == 0)
         {
             throw BusinessException.IllegalDepartmentId(input.DepartmentId);
         }
         validateSupervisorReferenceCycle(id, input.SupervisorId, new List <Employee>());
         return employeeRepository.Update(id, input) != 0;
     }
                ));
 }