public async Task <CustomerProfileErrorCodes> UpdateAsync(string customerId, string firstName, string lastName, string phoneNumber, int countryPhoneCodeId, int countryOfResidenceId) { var countryPhoneCode = await _dictionariesClient.Salesforce.GetCountryPhoneCodeByIdAsync(countryPhoneCodeId); if (countryPhoneCode == null) { return(CustomerProfileErrorCodes.InvalidCountryPhoneCodeId); } var e164FormattedNumber = PhoneUtils.GetE164FormattedNumber(phoneNumber, countryPhoneCode.IsoCode); if (e164FormattedNumber == null) { return(CustomerProfileErrorCodes.InvalidPhoneNumber); } var isPhoneNumberUsedByAnotherCustomer = await _customerProfileRepository.IsPhoneNumberUsedByAnotherCustomer(customerId, e164FormattedNumber); if (isPhoneNumberUsedByAnotherCustomer) { return(CustomerProfileErrorCodes.PhoneAlreadyExists); } var result = await _customerProfileRepository.UpdateAsync(customerId, firstName, lastName, e164FormattedNumber, phoneNumber, countryPhoneCodeId, countryOfResidenceId); if (result == CustomerProfileErrorCodes.CustomerProfileDoesNotExist) { _log.Warning("Customer profile does not exist so it was not updated", context: customerId); } return(result); }