Esempio n. 1
0
        static async Task Main(string[] args)
        {
            Console.Title = "Cliente Transações";

            var transactionService = LoadTransactionService();
            var logger             = new LoggerService();
            var applicationService = new TransactionApplicationService(transactionService, logger);

            //Exibe as últimas transações
            await applicationService.PrintTransactions();

            //Exibe o total de gastos por categoria
            await applicationService.PrintSpentValuesByCategory();

            //Exibe qual categoria cliente gastou mais;
            await applicationService.PrintMostSpentCategory();

            ConsoleHelper.WriteHeader("Estatisticas de Movimentações");

            //Exibe qual foi o mês que cliente mais gastou
            await applicationService.PrintMostSpentMonth();

            //Exibe quanto de dinheiro o cliente gastou
            await applicationService.PrintSpentValue();

            //Exibe quanto de dinheiro o cliente recebeu
            await applicationService.PrintReceivedValue();

            //Exibe saldo total de movimentações do cliente
            await applicationService.PrintTotalTransactionsAmount();

            Console.ReadKey();
        }
Esempio n. 2
0
        /// <summary>
        /// Informa qual foi o mês que cliente mais gastou;
        /// </summary>
        public static async Task PrintMostSpentMonth(this TransactionApplicationService clientService)
        {
            var month = await clientService.GetMostSpentMonth();

            Console.WriteLine(
                $"Mês que você mais gastou: {month.Key} (R$ {month.Value:N}).");
        }
Esempio n. 3
0
        /// <summary>
        /// Informa qual categoria cliente gastou mais;
        /// </summary>
        public static async Task PrintMostSpentCategory(this TransactionApplicationService clientService)
        {
            var category = await clientService.GetMostSpentCategory();

            if (!string.IsNullOrEmpty(category.Key))
            {
                Console.WriteLine(
                    $"A Categoria que você mais gastou foi {category.Key}. Nesta categoria, você gastou um total de R$ {category.Value:N}");
            }
        }
Esempio n. 4
0
        public TransactionApplicationServiceTests()
        {
            _testApiGateway = new TestApiGateways();

            _testTransactionService = new TransactionService(new List <ITransactionReader>
            {
                new TransactionApiReader(_testApiGateway),
            });

            AddSampleTransactions();
            _applicationService = new TransactionApplicationService(_testTransactionService);
        }
Esempio n. 5
0
        /// <summary>
        /// Exibe o total de gastos por categoria;
        /// </summary>
        public static async Task PrintSpentValuesByCategory(this TransactionApplicationService transactionService)
        {
            ConsoleHelper.WriteHeader("Total gasto por Categoria");
            var categories = await transactionService.GetSpentValuesByCategoryOrdered();

            if (categories.Count > 0)
            {
                ConsoleHelper.PrintRow("Categoria", "Total Gasto");
                categories.ToList().ForEach(c => ConsoleHelper.PrintRow(c.Key, c.Value.ToString("N")));
            }
            else
            {
                Console.WriteLine("Não há categorias.");
            }

            Console.WriteLine();
        }
Esempio n. 6
0
        /// <summary>
        /// Exibe as transações do cliente no Console, de forma ordenada.
        /// </summary>
        public static async Task PrintTransactions(this TransactionApplicationService transactionService)
        {
            var transactions = await transactionService.GetTransactionsOrdered();

            ConsoleHelper.WriteHeader("Últimas transações");
            if (transactions?.Count > 0)
            {
                ConsoleHelper.PrintRow("Data", "Descrição", "Valor", "Categoria");

                foreach (var clientTransaction in transactions)
                {
                    ConsoleHelper.PrintRow(clientTransaction.Date.ToShortDateString(),
                                           clientTransaction.Description,
                                           clientTransaction.Amount.ToString("N"),
                                           clientTransaction.Category);
                }
            }
            else
            {
                Console.WriteLine("Não foram encontradas últimas transações.");
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Informa quanto de dinheiro o cliente já recebeu.
        /// </summary>
        public static async Task PrintTotalTransactionsAmount(this TransactionApplicationService clientService)
        {
            var transactionsAmount = await clientService.GetTotalTransactionsAmount();

            Console.WriteLine($"Total Movimentado: R$ {transactionsAmount:N}");
        }
Esempio n. 8
0
        /// <summary>
        /// Informa quanto de dinheiro o cliente já recebeu.
        /// </summary>
        public static async Task PrintReceivedValue(this TransactionApplicationService clientService)
        {
            var receivedValue = await clientService.GetReceivedValue();

            Console.WriteLine($"Total Recebido: R$ {receivedValue:N}");
        }
Esempio n. 9
0
        /// <summary>
        /// Informa quanto de dinheiro o cliente gastou.
        /// </summary>
        public static async Task PrintSpentValue(this TransactionApplicationService clientService)
        {
            var spentMoney = await clientService.GetSpentValue();

            Console.WriteLine($"Total Gasto: R$ {spentMoney:N}");
        }