public async Task <CustomerProfileErrorCodes> UpdatePhoneInfoAsync(string customerId, string phoneNumber, int countryPhoneCodeId) { var customerProfile = await _customerProfileRepository.GetByCustomerIdAsync(customerId, includeNotVerified : true); if (customerProfile == null) { return(CustomerProfileErrorCodes.CustomerProfileDoesNotExist); } 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); } if (customerProfile.PhoneNumber == e164FormattedNumber && customerProfile.ShortPhoneNumber == phoneNumber && customerProfile.CountryPhoneCodeId == countryPhoneCodeId) { return(CustomerProfileErrorCodes.None); } var result = await _customerProfileRepository.UpdatePhoneInfoAsync(customerId, e164FormattedNumber, phoneNumber, countryPhoneCodeId, isPhoneVerified : false); return(result); }