public async Task <string> GetOrCreateReferralForCustomerIdAsync(Guid customerId) { var existingReferral = await _referralRepository.GetByCustomerIdAsync(customerId); if (existingReferral != null) { return(existingReferral.ReferralCode); } var referralCode = await GenerateReferralCodeAsync(customerId.ToString("D")); await _referralRepository.CreateIfNotExistAsync(new Domain.Models.Referral() { CustomerId = customerId, Id = Guid.NewGuid().ToString("D"), ReferralCode = referralCode }); return(referralCode); }