Ejemplo n.º 1
0
        public virtual void OnEdit()
        {
            if (SF.UsePermissions())
            {
                if (LS.CurrentUser.IsInRole("Admin"))
                {
                    List <string> PermissionsView = new List <string>();
                    PermissionsView.Add("Admin");
                    if (LS.CurrentHttpContext.Request["PermissionsView"] != null)
                    {
                        PermissionsView.AddRange(LS.CurrentHttpContext.Request.Form.GetValues("PermissionsView").ToList());
                    }
                    this.PermissionsView = SF.RolesListToString(PermissionsView);

                    List <string> PermissionsEdit = new List <string>();
                    PermissionsEdit.Add("Admin");
                    if (LS.CurrentHttpContext.Request["PermissionsEdit"] != null)
                    {
                        PermissionsEdit.AddRange(LS.CurrentHttpContext.Request.Form.GetValues("PermissionsEdit").ToList());
                    }
                    this.PermissionsEdit = SF.RolesListToString(PermissionsEdit);
                }
                else
                {
                    AbstractPage OldPage = LS.CurrentEntityContext.AbstractPages.FirstOrDefault(r => r.ID == ID);
                    LS.CurrentEntityContext.Entry(OldPage).State = EntityState.Detached;
                    this.PermissionsView = OldPage.PermissionsView;
                    this.PermissionsEdit = OldPage.PermissionsEdit;
                }
            }
        }
Ejemplo n.º 2
0
        public virtual void BeforeCreate(int ParentID)
        {
            AbstractPage Parent = LS.CurrentEntityContext.AbstractPages.FirstOrDefault(r => r.ID == ParentID);

            if (Parent == null)
            {
                List <string> GetRoleListView = SF.GetRoleList();
                List <string> GetRoleListEdit = SF.GetRoleList();
                GetRoleListView.Remove("Admin");
                GetRoleListEdit.Remove("Admin");
                GetRoleListEdit.Remove("Anonymous");
                this.PermissionsView = SF.RolesListToString(GetRoleListView);
                this.PermissionsEdit = SF.RolesListToString(GetRoleListEdit);
            }
            else
            {
                this.PermissionsView = Parent.PermissionsView;
                this.PermissionsEdit = Parent.PermissionsEdit;
            }
        }