/// <summary> /// Добавить паспортные данные /// </summary> /// <param name="addedPassport">DTO добавляемого паспорта</param> public Passport Add(PassportDto addedPassport) { Contract.Argument.IsNotNull(addedPassport, nameof(addedPassport)); var passport = _passportRepository.Create( nameRus: addedPassport.NameRus, nameEng: addedPassport.NameEng, surnameRus: addedPassport.SurnameRus, surnameEng: addedPassport.SurnameEng, patronymicNameRus: addedPassport.PatronymicNameRus, patronymicNameEng: addedPassport.PatronymicNameEng, birthPlace: addedPassport.BirthPlace, birthCountry: addedPassport.BirthCountry, citizenship: addedPassport.Citizenship, residence: addedPassport.Residence, residenceCountry: addedPassport.ResidenceCountry, residenceRegion: addedPassport.ResidenceRegion, identityDocument: addedPassport.IdentityDocument, issuePlace: addedPassport.IssuePlace, departmentCode: addedPassport.DepartmentCode, birthDate: addedPassport.BirthDate, issueDate: addedPassport.IssueDate, gender: addedPassport.Gender); return(passport); }
/// <summary> /// Выполнить команду Добавить или Обновить паспортные данные сотрудника /// </summary> /// <param name="employeeId">Идентификатор сотрудника</param> /// <param name="employeeDto">Паспортные данные для создания паспорта</param> /// <returns>Идентификатор паспорта</returns> public async Task <Guid> AddOrUpdatePassportAsync(Guid employeeId, PassportDto passportDto) { Contract.Argument.IsNotEmptyGuid(employeeId, nameof(employeeId)); Contract.Argument.IsNotNull(passportDto, nameof(passportDto)); var employee = await _employeeRepository.GetAsync(employeeId).ConfigureAwait(false); if (employee.PassportId.HasValue) { await _passportRepository.UpdateAsync(employee.PassportId.Value, passportDto).ConfigureAwait(false); } else { var passport = _passportRepository.Create( nameRus: passportDto.NameRus, surnameRus: passportDto.SurnameRus, nameEng: passportDto.NameEng, surnameEng: passportDto.SurnameEng, patronymicNameRus: passportDto.PatronymicNameRus, patronymicNameEng: passportDto.PatronymicNameEng, birthPlace: passportDto.BirthPlace, birthCountry: passportDto.BirthCountry, departmentCode: passportDto.DepartmentCode, citizenship: passportDto.Citizenship, identityDocument: passportDto.IdentityDocument, residence: passportDto.Residence, residenceCountry: passportDto.ResidenceCountry, residenceRegion: passportDto.ResidenceRegion, issuePlace: passportDto.IssuePlace, birthDate: passportDto.BirthDate, issueDate: passportDto.IssueDate, gender: passportDto.Gender); employee.SetPassportId(passport.Id); } _domainContext.SaveChanges(); return(employee.PassportId.Value); }