public List <ResultInfo> SaveChanges() { using (OutlayAPIManager manager = new OutlayAPIManager()) { List <ResultInfo> resultList = new List <ResultInfo>(); resultList.AddRange(manager.SaveTransaction(addedTransactions)); resultList.AddRange(manager.ModifyTransaction(modifiedTransactions)); resultList.AddRange(manager.DeleteTransaction(deletedTransactions)); return(resultList); } }
public void LoadTransactionToBDFromCSV(string path) { if (File.Exists(path)) { string[] transactionFileLines = File.ReadAllLines(path); string dateLoad = DateTime.Today.ToString("yyyy_MM_dd"); using (OutlayAPIManager manager = new OutlayAPIManager()) { List <TransactionDTO> transactionList = new List <TransactionDTO>(); for (int indexLine = 1; indexLine < transactionFileLines.Length; ++indexLine) { string[] columns = transactionFileLines[indexLine].Split(';'); TransactionDTO transaction = new TransactionDTO() { Date = DateTime.Parse(columns[0].Trim()), Amount = Double.Parse(columns[2].Trim(), System.Globalization.NumberStyles.AllowDecimalPoint), DetailTransaction = new DetailTransacionDTO() { Type = columns[1].Trim(), Code = "LOAD_CSV", Description = $"LOAD_CS_{dateLoad}" } }; transactionList.Add(transaction); } manager.SaveTransaction(transactionList); } } else { throw new Exception($"Path {path} not found"); } }