public ActionResult Create(State state) { if (ModelState.IsValid) { stateRepository.InsertOrUpdate(state); stateRepository.Save(); return RedirectToAction("Index"); } else { ViewBag.PossibleCountries = countryRepository.All; return View(); } }
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 void InsertOrUpdate(State state) { if (state.StateID == default(int)) { // New entity context.State.Add(state); } else { // Existing entity context.Entry(state).State = EntityState.Modified; } }
public ViewResult Search(State searchState) { if(searchState!=null) { } return View("Index",stateRepository.AllIncluding(state => state.Country)); }