public ActionResult getTransactionsBySKU(string sku) { decimal suma = 0; var sbRes = new StringBuilder(); var sb = new StringBuilder(); try { var trList = FileController.readDataFromFile( System.Configuration.ConfigurationManager.AppSettings["fileTransactions"]); if (!string.IsNullOrEmpty(sku)) { foreach (var item in trList) { if (item.sku == sku) { if (!item.currency.Equals("EUR")) { var currencyEUR = CurrencyController.ToEUR(item); sb.AppendLine(item.ToString() + " to EUR: " + Math.Round((Decimal)currencyEUR, 2)); suma += currencyEUR; } else if (item.currency.Equals("EUR")) { var amount = decimal.Parse(item.amount, new NumberFormatInfo() { NumberDecimalSeparator = "." }); sb.AppendLine(item.ToString() + " to EUR: " + Math.Round((Decimal)amount, 2)); suma += amount; } } } } else { MsgBox(System.Configuration.ConfigurationManager.AppSettings["emptyValueSKU"]); } } catch (Exception ex) { FileController.writeDataIntoLog(ex.StackTrace.ToString(), strLogFile); } sbRes.AppendLine(suma.ToString("#.##")); sbRes.Append(" €"); ViewData["total"] = sbRes.ToString(); ViewData["results"] = sb.ToString(); return(View("Index")); }
public ActionResult getAllTransactions() { var sb = new StringBuilder(); try { var trList = FileController.readDataFromFile( System.Configuration.ConfigurationManager.AppSettings["fileTransactions"]); foreach (var item in trList) { sb.AppendLine(String.Format("SKU: {0}, Amount: {1}, Currency: {2}", item.sku, item.amount, item.currency)); } } catch (Exception ex) { FileController.writeDataIntoLog(ex.StackTrace.ToString(), strLogFile); } ViewData["results"] = sb.ToString(); return(View("Index")); }