// // Summary: // /// Method responsible for create registry. /// // // Parameters: // command: // The command param. // public async Task <Address> AddAsync(AddressCommand command) { _validationResult = await _addressValidator.ValidateAsync(command); if (_validationResult.IsValid is false) { return(null); } if (command.PrimaryAddress is true) { Address currentPrimaryAddress = await _addressRepository.FindCurrentPrimaryAddressByPersonId(command.PersonId); if (currentPrimaryAddress != null) { currentPrimaryAddress.UpdatePrimaryAddress(false); await _addressRepository.UpdateAsync(currentPrimaryAddress); } } Person person = await _personRepository.FindAsync(command.PersonId); Address address = new Address(command.PostalCode, command.State, command.City, command.District, command.Street, command.StreetNumber, command.Complement, command.PrimaryAddress, person); await _addressRepository.AddAsync(address); await _entityAuditService.AddAsync("INS", nameof(Address), address); return(address); }
// // Summary: // /// Method responsible for create registry. /// // // Parameters: // command: // The command param. // public async Task <Person> AddAsync(PersonCommand command) { _validationResult = await _personValidator.ValidateAsync(command); if (_validationResult.IsValid is false) { return(null); } Person person = new Person(command.Name, command.BirthDate, new Cpf(command.Cpf), command.Phone, new Email(command.Email), command.Profile, command.ProfessionalDescription); await _personRepository.AddAsync(person); await _entityAuditService.AddAsync("INS", nameof(Person), person); return(person); }
// // Summary: // /// Method responsible for create registry. /// // // Parameters: // command: // The command param. // public async Task <Interview> AddAsync(InterviewCommand command) { _validationResult = await _interviewValidator.ValidateAsync(command); if (_validationResult.IsValid is false) { return(null); } Person person = await _personRepository.FindAsync(command.PersonId); Interview interview = new Interview(command.SchedulingDate, command.Squad, person); await _interviewRepository.AddAsync(interview); await _entityAuditService.AddAsync("INS", nameof(Interview), interview); return(interview); }