public ActionResult Create(AuthoringTable authoringtable) { bool permission = Authorization.GetAccess(table, HttpContext.User.Identity.Name, write); if (permission) { if (ModelState.IsValid) { authoringtable.ID = Guid.NewGuid(); authoringtable.CreatedBy = Guid.Parse(Session["userid"].ToString()); authoringtable.CreatedOn = DateTime.Now; db.AuthoringTables.AddObject(authoringtable); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CreatedBy = new SelectList(db.Users, "ID", "UserName", authoringtable.CreatedBy); ViewBag.ModifiedBy = new SelectList(db.Users, "ID", "UserName", authoringtable.ModifiedBy); return(View(authoringtable)); } else { return(RedirectToAction("Index", "Home")); } }
// // GET: /AuthoringTable/Details/5 public ActionResult Details(Guid id) { bool permission = Authorization.GetAccess(table, HttpContext.User.Identity.Name, read); if (permission) { AuthoringTable authoringtable = db.AuthoringTables.Single(a => a.ID == id && (a.IsDeleted == null || a.IsDeleted == false)); return(View(authoringtable)); } else { return(RedirectToAction("Index", "Home")); } }
// // GET: /AuthoringTable/Edit/5 public ActionResult Edit(Guid id) { bool permission = Authorization.GetAccess(table, HttpContext.User.Identity.Name, write); if (permission) { AuthoringTable authoringtable = db.AuthoringTables.Single(a => a.ID == id && (a.IsDeleted == null || a.IsDeleted == false)); ViewBag.CreatedBy = new SelectList(db.Users, "ID", "UserName", authoringtable.CreatedBy); ViewBag.ModifiedBy = new SelectList(db.Users, "ID", "UserName", authoringtable.ModifiedBy); return(View(authoringtable)); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult DeleteConfirmed(Guid id) { bool permission = Authorization.GetAccess(table, HttpContext.User.Identity.Name, delete); if (permission) { AuthoringTable authoringtable = db.AuthoringTables.Single(a => a.ID == id && (a.IsDeleted == null || a.IsDeleted == false)); //db.AuthoringTables.DeleteObject(authoringtable); authoringtable.ModifiedBy = Guid.Parse(Session["userid"].ToString()); authoringtable.ModifiedOn = DateTime.Now; authoringtable.IsDeleted = true; db.ObjectStateManager.ChangeObjectState(authoringtable, EntityState.Modified); db.SaveChanges(); return(RedirectToAction("Index")); } else { return(RedirectToAction("Index", "Home")); } }