コード例 #1
0
        public async Task <GetEmployerAccountTransactionsResponse> Handle(GetEmployerAccountTransactionsQuery message)
        {
            var result = await _validator.ValidateAsync(message);

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

            var transactions = await _dasLevyService.GetAccountTransactionsByDateRange(message.AccountId, message.FromDate, message.ToDate);

            var hasPreviousTransactions = await _dasLevyService.GetPreviousAccountTransaction(message.AccountId, message.FromDate, message.ExternalUserId) > 0;

            if (!transactions.Any())
            {
                return(GetResponse(message.HashedAccountId, message.AccountId, hasPreviousTransactions));
            }

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

            return(GetResponse(message.HashedAccountId, message.AccountId, transactions, hasPreviousTransactions));
        }
コード例 #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));
        }