public ActionResult Delete(int id) { using (var context = new SiteContext()) { var city = context.Cities.First(c => c.Id == id); context.Cities.Remove(city); context.SaveChanges(); return RedirectToAction("Index"); } }
public ActionResult Edit(City model) { using (var context = new SiteContext()) { var city = context.Cities.First(c => c.Id == model.Id); TryUpdateModel(city, new[] { "Name", "Title", "IsActive" }); context.SaveChanges(); return RedirectToAction("Index"); } }
public ActionResult Create(City model) { using (var context = new SiteContext()) { var city = new City(); TryUpdateModel(city, new[] {"Name", "Title", "IsActive"}); context.Cities.Add(city); context.SaveChanges(); return RedirectToAction("Index"); } }
public ActionResult Create(City model) { using (var context = new SiteContext()) { var company = new Company(); TryUpdateModel(company, new[] { "Name", "Title", "IsActive","Description","ImageSource" }); context.Companies.Add(company); context.SaveChanges(); return RedirectToAction("Index"); } }