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)); }
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")); } }
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)); } }