示例#1
0
        /// <summary>
        /// Sets data for edit mode
        /// </summary>
        /// <param name="r">resource</param>
        /// <param name="roles">List of roles</param>
        /// <param name="allowed">List of allowed roles</param>
        public void setEditData(resource r, List<role> roles, List<role> allowed)
        {
            _action = new CMS_Action("/backend/EditResource?id=" + r.id);

            this._elements["name"].setValue(r.name);
            this._elements["controller"].setValue(r.controller);
            this._elements["action"].setValue(r.action);

            CMS_Form_Element submit = this._elements["ok"];
            this._elements.Remove("ok");

            List<long> allowedIds = allowed.Select(x => x.id).ToList();

            foreach (role roleItem in roles)
            {
                CMS_Form_Element_Select s = new CMS_Form_Element_Select("role_"+roleItem.id);
                s.setLabel("Acces for role "+roleItem.name);
                s.addOption("-1","Please choose");
                s.addOption("1","Allow");
                s.addOption("0","Deny");

                if (allowedIds.Contains(roleItem.id))
                {
                    s.setValue("1");
                }
                else
                {
                    s.setValue("0");
                }

                this.addElement(s);
            }
            this.addElement(submit);

            this._elements["ok"].setLabel("Save changes");
        }
示例#2
0
 partial void Deleteresource(resource instance);
示例#3
0
 partial void Updateresource(resource instance);
示例#4
0
 partial void Insertresource(resource instance);