/// <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"); }
partial void Deleteresource(resource instance);
partial void Updateresource(resource instance);
partial void Insertresource(resource instance);