public void ImportTransactions(string filePath, Guid accountId)
        {
            var lines = File.ReadAllLines(filePath)
                        .Where(x => !string.IsNullOrEmpty(x))
                        .ToArray();

            var transactionsResult = _transactionsParser.ParseTransactions(lines);

            if (transactionsResult.IsSuccess)
            {
                var account    = _accountStorage.Get(accountId);
                var sideEffect = account.AddTransactions(transactionsResult.Value);
                _accountStorage.Apply(sideEffect);
            }
            else
            {
                Console.WriteLine(transactionsResult.ErrorMessage);
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            var transactionsParser = new TransactionsParser();

            var res = transactionsParser.ParseTransactions(new string[] { });


            var accountStorage       = new AccountStorage();
            var transactionsImporter = new TransactionsImporter(accountStorage, transactionsParser);

            var accountGuid = Guid.Parse("a7fce19b-ab94-4e4f-891c-6003dce94aa0");
            var account     = new Account(accountGuid);

            accountStorage.Save(account);

            while (Console.ReadLine() != "exit")
            {
                Console.WriteLine("Importing transactions...");
                transactionsImporter.ImportTransactions("transactions.txt", account.Id);

                var updatedAccount = accountStorage.Get(accountGuid);
                Console.WriteLine($"Account contains {updatedAccount.Transactions.Count} transactions");
            }
        }