public async Task <ReferralHotel> ConfirmAsync(string confirmationToken) { var referralHotelEncrypted = await _referralHotelsRepository.GetByConfirmationTokenAsync(confirmationToken); if (referralHotelEncrypted == null) { throw new ReferralDoesNotExistException(); } if (referralHotelEncrypted.State == ReferralHotelState.Confirmed) { return(await DecryptAsync(referralHotelEncrypted)); } if (await ConfirmedReferralExistsAsync(referralHotelEncrypted.EmailHash)) { throw new ReferralAlreadyConfirmedException(); } if (ReferralExpired(referralHotelEncrypted)) { referralHotelEncrypted.State = ReferralHotelState.Expired; await _referralHotelsRepository.UpdateAsync(referralHotelEncrypted); throw new ReferralExpiredException(referralHotelEncrypted.Id); } referralHotelEncrypted.State = ReferralHotelState.Confirmed; referralHotelEncrypted = await _referralHotelsRepository.UpdateAsync(referralHotelEncrypted); _log.Info("Referral hotel confirmed", context: $"referralHotelId: {referralHotelEncrypted.Id}"); return(await DecryptAsync(referralHotelEncrypted)); }
public async Task <ReferralHotel> GetReferralHotelByConfirmationTokenAsync(string confirmationToken) { var hotelReferralEncrypted = await _referralHotelsRepository.GetByConfirmationTokenAsync(confirmationToken); return(await DecryptAsync(hotelReferralEncrypted)); }