public ActionResult Create(Country country) { if (ModelState.IsValid) { countryRepository.InsertOrUpdate(country); countryRepository.Save(); return RedirectToAction("Index"); } else { return View(); } }
public void InsertOrUpdate(Country country) { if (country.CountryID == default(int)) { // New entity context.Country.Add(country); } else { // Existing entity context.Entry(country).State = EntityState.Modified; } }
public static string GetLocation(string strCityName, State state, Country country) { string strLocation = strCityName.ToString(true).Trim(); if (state != null && state.Name.IsNotNullOrEmpty()) { strLocation = strLocation.Concate(", ", state.Name.Trim()); } if (country != null && country.Name.IsNotNullOrEmpty()) { strLocation = strLocation.Concate(", ", country.Name.Trim()); } return strLocation; }
public ViewResult Search(Country searchCountry) { if(searchCountry!=null) { } return View("Index",countryRepository.All); }