示例#1
0
        private async Task <decimal> GetAccountBalance(long accountId)
        {
            try
            {
                _logger.Info($"Getting current funds balance for account ID: {accountId}");

                return(await _levyService.GetAccountBalance(accountId));
            }
            catch (Exception e)
            {
                _logger.Error(e, $"Failed to get account's current balance for account ID: {accountId}");

                throw;
            }
        }
示例#2
0
        public async Task <GetEmployerAccountTransactionsResponse> Handle(GetEmployerAccountTransactionsQuery message)
        {
            var result = await _validator.ValidateAsync(message);

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

            if (result.IsUnauthorized)
            {
                throw new UnauthorizedAccessException();
            }

            var toDate   = CalculateToDate(message);
            var fromDate = new DateTime(toDate.Year, toDate.Month, 1);

            var accountId    = _hashingService.DecodeValue(message.HashedAccountId);
            var transactions = await _dasLevyService.GetAccountTransactionsByDateRange(accountId, fromDate, toDate);

            var balance = await _dasLevyService.GetAccountBalance(accountId);

            var hasPreviousTransactions = await _dasLevyService.GetPreviousAccountTransaction(accountId, fromDate) > 0;

            foreach (var transaction in transactions)
            {
                await GenerateTransactionDescription(transaction);
            }

            PopulateTransferPublicHashedIds(transactions);

            return(GetResponse(
                       message.HashedAccountId,
                       accountId,
                       transactions,
                       balance,
                       hasPreviousTransactions,
                       toDate.Year,
                       toDate.Month));
        }