public List<Models.ExchangeRate> parseExchangeRates() { CsvReader csv = new CsvReader(reader, true); int fieldCount = csv.FieldCount; List<ExchangeRate> exList = new List<ExchangeRate>(); ExchangeRate exObj = null; String[] headers = csv.GetFieldHeaders(); while (csv.ReadNextRecord()) { exObj = new ExchangeRate(); for (int i = 0; i < fieldCount; i++) { // this is where you actually create your dB object if (headers[i].Equals("fromCurrency")) { exObj.fromCurrency = csv[i]; } else if (headers[i].Equals("toCurrency")) { exObj.toCurrency = csv[i]; } else if (headers[i].Equals("rate")) { exObj.rate = Convert.ToDouble(csv[i]); } } exList.Add(exObj); } return exList; //throw new NotImplementedException(); }
public ActionResult Create(ExchangeRate exchangerate) { if (ModelState.IsValid) { db.exchangeRates.Add(exchangerate); db.SaveChanges(); return RedirectToAction("Index"); } return View(exchangerate); }
public ActionResult Edit(ExchangeRate exchangerate) { if (ModelState.IsValid) { db.Entry(exchangerate).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(exchangerate); }