public void CreateEmployee(DomainEntity.Employee entity) { try { var employeeRepository = _unitOfWork.Repository <DbEntity.Employee>(); employeeRepository.Insert(_mapper.Map <DomainEntity.Employee, DbEntity.Employee>(entity)); _unitOfWork.Commit(); } catch (Exception ex) { // Error logic // .... _unitOfWork.Rollback(); throw new Exception(ex.Message, ex); } }
public static EmployeeViewModel DomainToView(this DomainEntity.Employee @this) { EmployeeViewModel view = new EmployeeViewModel { employee_id = @this.employee_id, birth_date = @this.birth_date, education = (Education)(int)@this.education, first_name = @this.first_name, last_name = @this.last_name, date_on = @this.date_on, state = (EmployeeState)(int)@this.state, registration_address = @this.registration_address }; if (@this.date_off != null) { view.IsDismissed = true; view.dismissed_date = @this.date_off; } if (@this.group_id != null) { view.group = new EmployeeGroupViewModel(); view.group.group_id = @this.group_id.Value; view.group.group_name = @this.Group.description; } if (@this.position_id != null) { view.position = new EmployeePositionViewModel(); view.position.position_id = @this.position_id.Value; view.position.position_name = @this.Position.name; } return(view); }