public void Maps_IsLevyPayer_From_ApprenticeshipUpdated_To_ApprenticeshipModel_Correctly()
        {
            var approvalsEvent = new ApprenticeshipUpdated
            {
                IsLevyPayer = true
            };
            var model = Mapper.Map <ApprenticeshipModel>(approvalsEvent);

            model.IsLevyPayer.Should().BeTrue();
        }
예제 #2
0
        public async Task HandleApprenticeshipUpdated(ApprenticeshipUpdated message, CancellationToken none)
        {
            using (var operation = telemetry.StartOperation("DataLockService.HandleApprenticeshipUpdated", message.EventId.ToString()))
            {
                var stopwatch = Stopwatch.StartNew();
                await Initialise().ConfigureAwait(false);

                await apprenticeshipUpdatedProcessor.ProcessApprenticeshipUpdate(message);

                TrackInfrastructureEvent("DataLockService.HandleApprenticeshipUpdated", stopwatch, message);
                telemetry.StopOperation(operation);
            }
        }
예제 #3
0
        public async Task <List <DataLockEvent> > GetApprenticeshipUpdatedPayments(ApprenticeshipUpdated message, CancellationToken none)
        {
            using (var operation = telemetry.StartOperation("DataLockService.HandleApprenticeshipUpdated", message.EventId.ToString()))
            {
                var stopwatch = Stopwatch.StartNew();
                await Initialise().ConfigureAwait(false);

                var payments = await apprenticeshipUpdatedProcessor.GetApprenticeshipUpdatePayments(message).ConfigureAwait(false);

                TrackInfrastructureEvent("DataLockService.GetApprenticeshipUpdatedPayments", stopwatch);
                telemetry.StopOperation(operation);

                return(payments);
            }
        }
        public void SetUp()
        {
            mocker = AutoMock.GetLoose();
            mocker.Provide <IMapper>(mapper);
            mocker.Mock <IActorDataCache <List <ApprenticeshipModel> > >()
            .Setup(x => x.AddOrReplace(It.IsAny <string>(), It.IsAny <List <ApprenticeshipModel> >(),
                                       It.IsAny <CancellationToken>()))
            .Returns(Task.CompletedTask);

            updatedApprenticeship = new ApprenticeshipUpdated
            {
                Id                = 123,
                Ukprn             = 123456,
                Uln               = 54321,
                EmployerAccountId = 1234
            };
        }
예제 #5
0
        private void TrackInfrastructureEvent(string eventName, Stopwatch stopwatch, ApprenticeshipUpdated message = null)
        {
            var properties = new Dictionary <string, string>();

            if (message == null)
            {
                properties.Add("No identifier", "No identifier");
            }
            else
            {
                properties.Add(TelemetryKeys.Ukprn, message.Ukprn.ToString());
                properties.Add("ApprenticeshipId", message.Id.ToString());
            }
            telemetry.TrackEvent(eventName, properties,
                                 new Dictionary <string, double>
            {
                { TelemetryKeys.Duration, stopwatch.ElapsedMilliseconds }
            });
        }
예제 #6
0
        public async Task ProcessApprenticeshipUpdate(ApprenticeshipUpdated updatedApprenticeship)
        {
            logger.LogDebug(
                $"Getting apprenticeships cache item using uln for apprenticeship id: {updatedApprenticeship.Id}");
            var cacheItem = await dataCache.TryGet(updatedApprenticeship.Uln.ToString(), CancellationToken.None);

            logger.LogDebug(cacheItem.HasValue
                ? "Item found in the cache."
                : "No cache item found. Will now create new apprenticeships list.");
            var apprenticeships = cacheItem.HasValue ? cacheItem.Value : new List <ApprenticeshipModel>();

            logger.LogDebug("Removing old version of the apprenticeship.");
            apprenticeships.RemoveAll(apprenticeship => apprenticeship.Id == updatedApprenticeship.Id);
            logger.LogDebug("Now mapping the ApprenticeshipUpdated event to the ApprenticeshipModel.");
            var model = mapper.Map <ApprenticeshipModel>(updatedApprenticeship);

            logger.LogDebug("Finished mapping the apprenticeship model, now adding to the cache.");
            apprenticeships.Add(model);
            await dataCache.AddOrReplace(model.Uln.ToString(), apprenticeships, CancellationToken.None);

            logger.LogInfo(
                $"Finished storing the apprenticeship details in the cache. Apprenticeship id: {model.Id}, Account: {model.AccountId}, Provider: {model.Ukprn}");
            await AddUkprnToProviderCache(updatedApprenticeship.Ukprn);
        }
예제 #7
0
 public async Task <List <FunctionalSkillDataLockEvent> > GetApprenticeshipUpdateFunctionalSkillPayments(ApprenticeshipUpdated updatedApprenticeship)
 {
     return(null);
 }
예제 #8
0
 public async Task <List <DataLockEvent> > GetApprenticeshipUpdatePayments(ApprenticeshipUpdated updatedApprenticeship)
 {
     return(null);
 }