public void CreateDepartment(DepartmentDto departmentDto) { try { using (var httpRequestScope = AutofacHostFactory.Container.BeginLifetimeScope(MatchingScopeLifetimeTags.RequestLifetimeScopeTag)) { var employeeService = httpRequestScope.Resolve<IEmployeeManager>(); var department = this.ConvertToEntity(departmentDto); employeeService.CreateDepartment(department); } } catch (Exception ex) { throw new FaultException(ex.Message); } }
private Department ConvertToEntity(DepartmentDto departmentDto) { return new Department { Name = departmentDto.Name, Leader = this.dtoToEmployeeMapper.Map(departmentDto.Leader), Employees = departmentDto.Employees.Select(this.dtoToEmployeeMapper.Map).ToList() }; }