/// <summary> /// Adds a new role /// </summary> /// <param name="parent">Parent role</param> /// <param name="form">Role data</param> /// <returns>success</returns> public bool add(long parent, Form_Role_Add form) { role r = new role(); r.date = DateTime.Now; r.parentid = parent; if (parent == 0) { r.parentid = null; } r.name = form["name"].getValue(); using (ACLDataContext a = new ACLDataContext()) { a.roles.InsertOnSubmit(r); a.SubmitChanges(); } return true; }
/// <summary> /// Sets data for edit mode /// </summary> /// <param name="r">role</param> public void setEditData(role r) { this._action = new CMS_Action("/backend/editRole?id=" + r.id); this._elements["name"].setValue(r.name); this._elements["ok"].setLabel("Save changes"); }
private void detach_roles(role entity) { this.SendPropertyChanging(); entity.role1 = null; }
private void attach_roles(role entity) { this.SendPropertyChanging(); entity.role1 = this; }
partial void Deleterole(role instance);
partial void Updaterole(role instance);
partial void Insertrole(role instance);
/// <summary> /// Save changes to the given role /// </summary> /// <param name="form">Role data</param> /// <param name="r">Role</param> /// <returns>success</returns> public bool save(Form_Role_Add form, role r) { role newRole = new role(); newRole.id = r.id; if (r.parentid.HasValue) { newRole.parentid = r.parentid; } newRole.name = form["name"].getValue(); newRole.date = r.date; using (ACLDataContext a = new ACLDataContext()) { a.roles.Attach(newRole, r); a.SubmitChanges(); } return true; }