/// <inheritdoc/> public async Task <BusinessPerson> UpdateAsync(BusinessPerson person) { if (person == null) { throw new ArgumentNullOrEmptyException(nameof(person), ExceptionResources.ArgumentNullOrEmptyException_RequiredPersonData); } DataPerson foundPerson = await this.FindWithGuardsAsync(person.Identifier).ConfigureAwait(false); if (foundPerson == null) { return(null); } DataPerson editedDataPerson = this._mapper.Map(person, foundPerson); DataPerson updatedDataPerson = await this._personRepository.UpdateAsync(editedDataPerson).ConfigureAwait(false); if (updatedDataPerson == null) { throw new FailedActionException(ExceptionResources.FailedActionException_EditActionName, ExceptionResources.FailedActionException_EditPersonExceptionMessage); } BusinessPerson updatedPerson = updatedDataPerson.ToBusiness(this._mapper); return(updatedPerson); }
/// <inheritdoc/> public async Task <BusinessPerson> ReadAsync(Guid identifier) { DataPerson foundPerson = await this.FindWithGuardsAsync(identifier).ConfigureAwait(false); if (foundPerson == null) { return(null); } return(foundPerson.ToBusiness(this._mapper)); }
/// <inheritdoc/> public async Task <BusinessPerson> DeteleAsync(Guid identifier) { DataPerson foundPerson = await this.FindWithGuardsAsync(identifier).ConfigureAwait(false); if (foundPerson == null) { return(null); } DataPerson deletedPerson = await this._personRepository.DeteleAsync(foundPerson).ConfigureAwait(false); if (deletedPerson == null) { return(null); } return(deletedPerson.ToBusiness(this._mapper)); }
/// <inheritdoc/> public async Task <BusinessPerson> CreateAsync(BusinessPerson person) { if (person == null) { throw new ArgumentNullOrEmptyException(nameof(person), ExceptionResources.ArgumentNullOrEmptyException_RequiredPersonData); } DataPerson newPerson = person.ToData(this._mapper); newPerson.Identifier = Guid.NewGuid(); DataPerson editedDataPerson = await this._personRepository.CreateAsync(newPerson).ConfigureAwait(false); if (editedDataPerson == null) { throw new FailedActionException(ExceptionResources.FailedActionException_EditActionName, ExceptionResources.FailedActionException_EditPersonExceptionMessage); } return(editedDataPerson.ToBusiness(this._mapper)); }