Beispiel #1
0
        public async Task <double> GetLkkSoldAmount()
        {
            var lkk = await _assetsDictionary.GetItemAsync(LykkeConstants.LykkeAssetId);

            var walletsToTrack = await _lkkSourceWalletsRepository.GetRecordsAsync();

            double result = 0;

            var balancesTasks =
                walletsToTrack.Select(
                    x =>
                    _srvBlockchainReader.GetBalanceForAdress(x.Address, lkk)
                    .ContinueWith(task => x.StartBalance - task.Result.Balance));

            var balances = await Task.WhenAll(balancesTasks);

            result += balances.Sum();

            result += (await _appGlobalSettingsRepositry.GetAsync()).IcoLkkSold;

            var maxValue =
                (await _tempDataRepository.RetrieveData <IcoCoinsBoughtData>())?.MaxValue ?? 0;

            if (result > maxValue)
            {
                await _tempDataRepository.InsertOrReplaceDataAsync(new IcoCoinsBoughtData { MaxValue = result });

                maxValue = result;
            }

            return(maxValue);
        }
Beispiel #2
0
        public static async Task <bool> ShouldShowBackupWarning(this ITempDataRepository repo, string clientId, int timeoutInMinutes)
        {
            var lastWarningDt = (await repo.RetrieveData <BackupWarningTimeoutData>(clientId))?.LastWarningDt;

            if (lastWarningDt == null || DateTime.UtcNow - lastWarningDt > TimeSpan.FromMinutes(timeoutInMinutes))
            {
                await repo.InsertOrReplaceDataAsync(new BackupWarningTimeoutData { LastWarningDt = DateTime.UtcNow },
                                                    clientId);

                return(true);
            }

            return(false);
        }