Esempio n. 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;
     }
 }
Esempio n. 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();
     }
 }
Esempio n. 3
0
 public ViewResult Search(City searchCity)
 {
     if(searchCity!=null)
     {
                     }
                 return View("Index",cityRepository.AllIncluding(city => city.Country, city => city.State));
 }