public async Task <int> getFamilyHumanIdAsync(string humanId) { if (!string.IsNullOrEmpty(humanId)) { return(int.Parse(humanId)); } return(await _HumamRepository.FindMaxIdAsync() + 1); //TODO:採番は、テーブルにするか採番テーブルにするか。 }
public async Task <UserCreateResponse> Handle(UserCreateRequest request) { if (_EmployeeService.Exists(request.EmployeeId)) { throw new DuplicateDataException(request.EmployeeId); } Optional <Employee> emp = await _EmployeeRepository.FindByAsync(request.EmployeeId); //TODO:Factory //TODO:Domainサービスに移行 var maxHumanID = await _HumamRepository.FindMaxIdAsync() + 1; Employee newEmp = new Employee( employeeId: new EmployeeId(request.EmployeeId), email: new Email(request.Email), employeeAttr: new Human( humanId: new HumanId(maxHumanID), fullName: new FullName(request.FirstName, request.LastName), sex: new Sex(request.Sex), birthday: new Birthday(request.Birthday), relationship: new Relationship("0") //TODO ) ); await _EmployeeRepository.SaveAsync(newEmp); _EmployeeRepository.SaveChangedAsync(); return(new UserCreateResponse( employeeId: newEmp.EmployeeId.Value, email: newEmp.Email.Value, humanId: newEmp.HumanId, firstName: newEmp.FirstName, lastName: newEmp.LastName, sex: newEmp.Sex, birthday: newEmp.Birthday, createdBy: "", //TODO createdOn: DateTime.Now, //TODO updatedBy: "", //TODO. updatedOn: DateTime.Now //TODO )); }