private async Task Initialise()
        {
            if (!long.TryParse(Id.ToString(), out _))
            {
                throw new InvalidCastException($"Unable to cast Actor Id {Id} to valid account Id ");
            }

            if (await actorCache.IsInitialiseFlagIsSet().ConfigureAwait(false))
            {
                paymentLogger.LogVerbose($"Actor already initialised for employer {Id}");
                return;
            }

            var stopwatch = Stopwatch.StartNew();

            paymentLogger.LogInfo($"Initialising actor for employer {Id}");

            await actorCache.SetInitialiseFlag().ConfigureAwait(false);

            paymentLogger.LogInfo($"Initialised actor for employer {Id}");
            TrackInfrastructureEvent("LevyFundedService.Initialise", stopwatch);
        }
Esempio n. 2
0
        private async Task Initialise()
        {
            if (await actorCache.IsInitialiseFlagIsSet().ConfigureAwait(false))
            {
                paymentLogger.LogVerbose($"Actor already initialised for employer {Id}");
                return;
            }

            var stopwatch = Stopwatch.StartNew();

            paymentLogger.LogInfo($"Initialising actor for employer {Id.GetLongId()}");

            var paymentPriorities = await levyFundingSourceRepository.GetPaymentPriorities(Id.GetLongId()).ConfigureAwait(false);

            await employerProviderPriorities
            .AddOrReplace(CacheKeys.EmployerPaymentPriorities, paymentPriorities, default(CancellationToken))
            .ConfigureAwait(false);

            await actorCache.SetInitialiseFlag().ConfigureAwait(false);

            paymentLogger.LogInfo($"Initialised actor for employer {Id.GetLongId()}");
            TrackInfrastructureEvent("LevyFundedService.Initialise", stopwatch);
        }