예제 #1
0
        public ActionResult Delete(int?countryPK)
        {
            ICountriesRepository countriesRepository = new CountriesRepository(db);

            if (countryPK != null)
            {
                Country country = countriesRepository.GetCountryByPK((int)countryPK);

                country.Deleted = true;

                countriesRepository.SaveChanges();

                TempData["message"] = LayoutHelper.GetMessage("DELETE", country.CountryPK);
            }

            return(Redirect(Request.UrlReferrer.AbsoluteUri));
        }
예제 #2
0
        public ActionResult Edit(int?countryPK)
        {
            if (countryPK != null)
            {
                ICountriesRepository countriesRepository = new CountriesRepository(db);

                Country country = countriesRepository.GetCountryByPK((int)countryPK);

                CountryView countryView = new CountryView();
                countryView.ConvertFrom(country, countryView);

                return(View(countryView));
            }
            else
            {
                return(RedirectToAction("Index", "Country"));
            }
        }
예제 #3
0
        public ActionResult Edit(CountryView countryView)
        {
            if (ModelState.IsValid)
            {
                ICountriesRepository countriesRepository = new CountriesRepository(db);
                Country country = countriesRepository.GetCountryByPK((int)countryView.CountryPK);

                countryView.ConvertTo(countryView, country);

                countriesRepository.SaveChanges();

                TempData["message"] = LayoutHelper.GetMessage("UPDATE", country.CountryPK);

                return(RedirectToAction("Index", "Country"));
            }
            else
            {
                return(View(countryView));
            }
        }