Exemplo n.º 1
0
        public List <Transactions> TransactionLists(Account accountToTransact)
        {
            try
            {
                var fileName = @"C:\Source\acadotnet\BankWorm\transactionfile-data.csv";
                var lines    = File.ReadAllLines(fileName).ToList().Skip(1);

                if (accountToTransact.Transactions == null)
                {
                    accountToTransact.Transactions = new List <Transactions>();
                }

                foreach (var line in lines)
                {
                    var cells = line.Split(',');
                    var tfv   = new Transactions
                    {
                        TransactionDate   = DateTime.Parse(cells[0]),
                        TypeOfTransaction = TransactionTypeExt.TransactionConvert(cells[2])
                    };
                    accountToTransact.Transactions.Add(tfv);
                }

                return(accountToTransact.Transactions);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 2
0
        public void PopulateAccount(Account accountToPopulate)
        {
            try
            {
                var fileName2 = @"C:\Source\acadotnet\BankWorm\transactionfile-data.csv";
                var lines     = File.ReadAllLines(fileName2).ToList().Skip(1);

                if (accountToPopulate.Transactions == null)
                {
                    accountToPopulate.Transactions = new List <Transactions>();
                }

                foreach (var line in lines)
                {
                    var cells = line.Split(',');
                    var tfv   = new Transactions
                    {
                        TransactionDate   = DateTime.Parse(cells[0]),
                        Memo              = cells[1],
                        TypeOfTransaction = TransactionTypeExt.TransactionConvert(cells[2]),
                        Amount            = Convert.ToDecimal(cells[3]),
                    };
                    accountToPopulate.Transactions.Add(tfv);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }