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()); } }
// GET: PageAdmin/Edit/5 public ActionResult Edit(short id) { var model = new AdHocPageModel(); using (var repo = new AdHocPageRepository()) { var entity = repo.GetById(id); model.Id = id; model.Url = entity.Url; model.Test = entity.Test; } return(View(model)); }
// GET: PageAdmin/Delete/5 public ActionResult Delete(short id) { var model = new AdHocPageModel(); using (var repo = new AdHocPageRepository()) { var entity = repo.GetById(id); model.Id = id; model.Url = entity.Url; model.Test = entity.Test; } return View(model); }
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(); } }