public void InsertOperationsBulkData(string data, String accountNumber) { var account = _repository.Find <Account>(x => x.Number == accountNumber).FirstOrDefault(); if (account == null) { throw new Exception("Could not find specified account using the account number"); } using (var reader = new StringReader(data)) { var operations = CSVProcessing.GetTransactionsFromCSV(reader); using (TransactionScope scope = new TransactionScope()) { foreach (var operation in operations) { operation.Account = account; _repository.Save <Operation>(operation); } scope.Complete(); } } }
public void GetTransactionsFromCSVTestCSV() { using (TextReader reader = new StreamReader(@"transactions.csv")) { IEnumerable <Operation> actual; actual = CSVProcessing.GetTransactionsFromCSV(reader); Assert.IsTrue(actual.Count() > 0); } }
public void GetTransactionsFromCSVTest() { var text = "date,description,amount\n" + "25/11/2011,RETRAIT DAB 24/11/11 19H35 169770 BNP PARIBAS PARIS ,\"-60,00\"\n" + "25/11/2011,VIREMENT RECU TIERS OCTO TECHNOLOGY VIREMENT SALAIRES NOVEMB ,\"2.023,96\""; using (TextReader reader = new StringReader(text)){ var actual = CSVProcessing.GetTransactionsFromCSV(reader).ToList(); Assert.IsTrue(actual.Count() == 2); Assert.AreEqual(actual.First().Amount, 60); } }
public bool ProcessPayments() { var filePath = "/Data/CBSinput.txt"; List <Operation> operations = new List <Operation>(); using (var reader = new StreamReader(filePath)) { var transactions = CSVProcessing.GetTransactionsFromCSV(reader); using (TransactionScope scope = new TransactionScope()) { foreach (var transaction in transactions) { _repository.Save(transaction); } scope.Complete(); } } return(true); }