Пример #1
0
        public async Task <GetApprenticeshipsResponse> Handle(GetApprenticeshipsRequest message)
        {
            var validationResult = _validator.Validate(message);

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

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

            try
            {
                return(new GetApprenticeshipsResponse
                {
                    Apprenticeships = await _commitmentV2Service.GetApprenticeships(accountId)
                });
            }
            catch (Exception ex)
            {
                _logger.Error(ex, $"Failed to get Cohorts for {message.HashedAccountId}");
                return(new GetApprenticeshipsResponse
                {
                    HasFailed = true
                });
            }
        }
Пример #2
0
 public async Task <IEnumerable <Apprenticeship> > GetApprenticeships(long accountId)
 {
     try
     {
         return(await _pollyPolicy.ExecuteAsync(() => _commitmentsV2Service.GetApprenticeships(accountId)));
     }
     catch (TimeoutRejectedException ex)
     {
         throw new ServiceTimeoutException("Call to Commitments V2 Service timed out", ex);
     }
 }