public async Task <GetReservationsResponse> Handle(GetReservationsRequest message)
        {
            var validationResult = _validator.Validate(message);

            if (!validationResult.IsValid())
            {
                throw new InvalidRequestException(validationResult.ValidationDictionary);
            }

            long accountId = _hashingService.DecodeValue(message.HashedAccountId);

            _logger.Info($"Getting reservations for hashed account id {message.HashedAccountId}");

            try
            {
                return(new GetReservationsResponse
                {
                    Reservations = await _service.Get(accountId)
                });
            }
            catch (Exception ex)
            {
                _logger.Error(ex, $"Failed to get Reservations for {message.HashedAccountId}");
                return(new GetReservationsResponse
                {
                    HasFailed = true
                });
            }
        }
Esempio n. 2
0
        public async Task ThenTheReservationsAreReturnedFromTheApi()
        {
            // arrange

            // act
            var result = await _sut.Get(_accountId);

            // assert
            result.Count().Should().Be(1);
            result.First().AccountId.Should().Be(_accountId);
        }
Esempio n. 3
0
 public async Task <IEnumerable <Reservation> > Get(long accountId)
 {
     try
     {
         return(await _pollyPolicy.ExecuteAsync(() => _service.Get(accountId)));
     }
     catch (TimeoutRejectedException ex)
     {
         throw new ServiceTimeoutException("Call to Reservation Service timed out", ex);
     }
 }
Esempio n. 4
0
 public IEnumerable <ReservationDetail> Get(DateTime day, int assetNumber)
 {
     return(_service.Get(day, assetNumber));
 }