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()); } }
// 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)); }