public ActionResult Create(LocationViewModel model) { var context = new MvcBeginnerDataContext(); context.Locations.InsertOnSubmit(new Location { Title = model.Title }); context.SubmitChanges(); return(RedirectToAction("Index")); }
public ActionResult Delete(int id, LocationViewModel model) { var context = new MvcBeginnerDataContext(); var location = context.Locations.FirstOrDefault(l => l.Id == id); if (location == null) { return(RedirectToAction("Index")); } context.Locations.DeleteOnSubmit(location); context.SubmitChanges(); return(RedirectToAction("Index")); }