public PermissionManager(Models.Admin.AllowedSections CurrentSection) { this.CurrentSection = CurrentSection; MainDataContext db = MainDataContext.CurrentContext; Page page = HttpContext.Current.Handler as Page; _CanView = true; _CanAdd = true; _CanUpdate = true; _CanDelete = true; /* * if (((AdminPage)page).AdminUser.IsMasterAdmin) * { * _CanView = true; * _CanAdd = true; * _CanUpdate = true; * _CanDelete = true; * } * else * { * AdminPermission permission = db.AdminPermissions.SingleOrDefault(a => a.Section == (int)CurrentSection && a.AdminID == ((AdminPage)page).AdminUser.ID); * if (permission != null) * { * _CanView = true; * _CanAdd = permission.IsAdd; * _CanUpdate = permission.IsUpdate; * _CanDelete = permission.IsDelete; * } * }*/ /* this permission manager is now redundant*/ }
/// <summary> /// This checks the permissions for the currently logged in user and creates the PermissionManager /// </summary> /// <param name="section">The current section</param> protected void RunSecurity(Models.Admin.AllowedSections section) { _PermissionManager = new PermissionManager(section); /* * if (!PermissionManager.CanView) * Response.Redirect("/admin/nopermission.aspx?url=" + Request.RawUrl);*/ }