public ActionResult Edit(CurrencyView currencyModel) { if (ModelState.IsValid) { ICurrenciesRepository currenciesRepository = new CurrenciesRepository(db); Currency currency = currenciesRepository.GetCurrencyByPK((int)currencyModel.CurrencyPK); currencyModel.ConvertTo(currencyModel, currency); currenciesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("UPDATE", currency.CurrencyPK); return(RedirectToAction("Index", "Currency")); } else { return(View(currencyModel)); } }
public ActionResult Add(CurrencyView currencyView) { if (ModelState.IsValid) { ICurrenciesRepository currenciesRepository = new CurrenciesRepository(db); Currency currency = new Currency(); currencyView.ConvertTo(currencyView, currency); currenciesRepository.Add(currency); currenciesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("INSERT", currency.CurrencyPK); return(RedirectToAction("Index", "Currency")); } else { return(View(currencyView)); } }