Exemplo n.º 1
0
        public ActionResult Delete(int?currencyPK)
        {
            ICurrenciesRepository currenciesRepository = new CurrenciesRepository(db);

            if (currencyPK != null)
            {
                Currency currency = currenciesRepository.GetCurrencyByPK((int)currencyPK);

                currency.Deleted = true;

                currenciesRepository.SaveChanges();

                TempData["message"] = LayoutHelper.GetMessage("DELETE", currency.CurrencyPK);
            }

            return(Redirect(Request.UrlReferrer.AbsoluteUri));
        }
Exemplo n.º 2
0
        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));
            }
        }
Exemplo n.º 3
0
        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));
            }
        }