Пример #1
0
 public void InsertOrUpdate(City city)
 {
     if (city.CityID == default(int)) {
         // New entity
         context.City.Add(city);
     } else {
         // Existing entity
         context.Entry(city).State = EntityState.Modified;
     }
 }
Пример #2
0
 public ActionResult Create(City city)
 {
     if (ModelState.IsValid) {
         cityRepository.InsertOrUpdate(city);
         cityRepository.Save();
         return RedirectToAction("Index");
     } else {
         ViewBag.PossibleCountries = countryRepository.All;
         ViewBag.PossibleStates = stateRepository.All;
         return View();
     }
 }
Пример #3
0
 public ViewResult Search(City searchCity)
 {
     if(searchCity!=null)
     {
                     }
                 return View("Index",cityRepository.AllIncluding(city => city.Country, city => city.State));
 }