public ActionResult Create([Bind(Include = "Id,Name,Description")] Country country) { if (ModelState.IsValid) { db.Countries.Add(country); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(country)); }
/// <summary> /// Ensures that any created sample data is cleaned up. /// </summary> public void EmptySampleCountriesData() { using (var dataContext = new SeleniumDemoDataContext()) { // delete sample country var countries = dataContext.Countries; dataContext.Countries.RemoveRange(countries); dataContext.SaveChanges(); } }
/// <summary> /// Creates sample data relating to countries. /// </summary> /// <returns>Details of the created data.</returns> public CountriesKnownData EnsureSampleCountriesData() { using (var dataContext = new SeleniumDemoDataContext()) { var country = new Country { Name = KnownCountryName, Description = KnownCountryDescription }; dataContext.Countries.Add(country); dataContext.SaveChanges(); return(new CountriesKnownData { SampleCountry = country }); } }