public ActionResult Edit(int id, FormCollection collection) { try { var model = new AdHocPageModel(); UpdateModel(model); using (var repo = new AdHocPageRepository()) { var entity = repo.GetById(model.Id); entity.Url = model.Url; entity.User = UserIdentity.GetShortName(User); entity.Test = model.Test; repo.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(FormCollection collection) { try { var model = new AdHocPageModel(); UpdateModel(model); var entity = new AdHocPage { Url = model.Url, User = UserIdentity.GetShortName(User), Test = true }; using (var repo = new AdHocPageRepository()) { repo.Add(entity); repo.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(FormCollection collection) { try { var model = new AdHocPageModel(); UpdateModel(model); var entity = new AdHocPage { Url = model.Url, User = UserIdentity.GetShortName(User), Test = true }; using (var repo = new AdHocPageRepository()) { repo.Add(entity); repo.SaveChanges(); } return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Delete(int id, FormCollection collection) { try { using (var repo = new AdHocPageRepository()) { var entity = repo.GetById(id); repo.DbSet.Remove(entity); repo.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Delete(int id, FormCollection collection) { try { using (var repo = new AdHocPageRepository()) { var entity = repo.GetById(id); repo.DbSet.Remove(entity); repo.SaveChanges(); } return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Edit(int id, FormCollection collection) { try { var model = new AdHocPageModel(); UpdateModel(model); using (var repo = new AdHocPageRepository()) { var entity = repo.GetById(model.Id); entity.Url = model.Url; entity.User = UserIdentity.GetShortName(User); entity.Test = model.Test; repo.SaveChanges(); } return RedirectToAction("Index"); } catch { return View(); } }