public async Task <CustomerProfileErrorCodes> RequestCustomerProfileDeactivation(string customerId) { return(await _transactionRunner.RunWithTransactionAsync(async txContext => { var customerProfile = await _customerProfileRepository.GetByCustomerIdAsync(customerId, includeNotVerified: true, includeNotActive: true, txContext); if (customerProfile == null) { return CustomerProfileErrorCodes.CustomerProfileDoesNotExist; } if (customerProfile.Status != CustomerProfileStatus.Active) { return CustomerProfileErrorCodes.CustomerIsNotActive; } await _customerProfileRepository.ChangeProfileStatus(customerId, CustomerProfileStatus.PendingDeactivation, txContext); await _deactivationRequestedPublisher.PublishAsync(new CustomerProfileDeactivationRequestedEvent { CustomerId = customerId }); return CustomerProfileErrorCodes.None; })); }