public ActionResult Edit() { CitiesService citiesService = new CitiesService(); CitiesEditVM model = new CitiesEditVM(); TryUpdateModel(model); if (!ModelState.IsValid) { model.Countries = citiesService.GetSelectedCountries(); return View(model); } City city; if (model.ID == 0) { city = new City(); } else { city = citiesService.GetByID(model.ID); if (city == null) { return RedirectToAction("List"); } } city.ID = model.ID; city.Name = model.Name; city.PostCode = model.PostCode; city.CountryID = model.CountryID; citiesService.Save(city); return RedirectToAction("List"); }