public ActionResult SaveExchange(string parameterStr) { parameterStr = parameterStr.Replace('x', '.'); string[] parameters = parameterStr.Split(new[] { "," }, StringSplitOptions.None); if (parameters.Length > 1) { try { CurrencyYear refCY = FinancialControls.CurrencyYearList[Convert.ToInt32(parameters[0])]; double originalRate = refCY.ExchangeRates[Convert.ToInt32(parameters[1])]; // Update new rate refCY.ExchangeRates[Convert.ToInt32(parameters[1])] = Convert.ToDouble(parameters[2]); Log.Append(String.Format("Rate updated ({0} - {1}) : orig={2}, new={3}, by {4}", refCY.CurrencyType, refCY.Year, originalRate, parameters[2], HttpContext.Session["Email"])); ExcoExRate.SaveExchangeRates(FinancialControls.CurrencyYearList); } catch (Exception ex) { // Non-integer error } } return(RedirectToAction("ExchangeRates", new { parameterStr = "ER" })); }
public ActionResult AddExchange(string paramOne) { string[] parameters = paramOne.Split(new[] { "," }, StringSplitOptions.None); if (parameters.Length == 2 && !FinancialControls.CurrencyYearList.Any(x => x.Year.ToString() == parameters[0] && ExcoExRate.GetCurrency(parameters[1]) == x.CurrencyType)) { CurrencyYear newCY = new CurrencyYear(ExcoExRate.GetCurrency(parameters[1]), Convert.ToInt32(parameters[0])); // Instantiate 0 values for all 12 periods for (int i = 0; i < 12; i++) { newCY.ExchangeRates.Add(0); } FinancialControls.CurrencyYearList.Add(newCY); // Order by currency -> year FinancialControls.CurrencyYearList = FinancialControls.CurrencyYearList.OrderBy(x => x.CurrencyType) .ThenBy(y => y.Year).ToList(); ExcoExRate.SaveExchangeRates(FinancialControls.CurrencyYearList); } return(RedirectToAction("ExchangeRates")); }