public async Task <CachedReservation> GetProviderReservation(Guid id, uint ukPrn)
        {
            if (string.IsNullOrEmpty(id.ToString()) || id == Guid.Empty)
            {
                throw new ArgumentException("GUID is not set", nameof(id));
            }

            if (ukPrn == default(uint))
            {
                throw new ArgumentException("ukPrn is not set", nameof(ukPrn));
            }

            var cachedReservation = await _cacheStorage.RetrieveFromCache <CachedReservation>(id.ToString());

            if (cachedReservation == null)
            {
                throw new CachedReservationNotFoundException(id);
            }

            if (!_authorisationService.ProviderReservationAccessAllowed(ukPrn, cachedReservation))
            {
                throw new UnauthorizedAccessException();
            }

            return(cachedReservation);
        }
        public async Task <GetReservationResult> Handle(GetReservationQuery request, CancellationToken cancellationToken)
        {
            var validationResult = await _validator.ValidateAsync(request);

            if (!validationResult.IsValid())
            {
                throw new ValidationException(validationResult.ConvertToDataAnnotationsValidationResult(), null, null);
            }

            var apiRequest = new ReservationApiRequest(_options.Url, request.Id);

            var result = await _apiClient.Get <GetReservationResponse>(apiRequest);

            if (request.UkPrn != default(uint) && !await _reservationAuthorisationService.ProviderReservationAccessAllowed(request.UkPrn, result))
            {
                throw new UnauthorizedAccessException();
            }

            return(new GetReservationResult
            {
                ReservationId = result.Id,
                StartDate = result.StartDate,
                ExpiryDate = result.ExpiryDate,
                Course = result.Course ?? new Course(null, null, 0),
                AccountLegalEntityId = result.AccountLegalEntityId,
                AccountLegalEntityName = result.AccountLegalEntityName,
                UkPrn = result.ProviderId
            });
        }