示例#1
0
        /// <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;
        }
示例#2
0
 /// <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");
 }
示例#3
0
		private void detach_roles(role entity)
		{
			this.SendPropertyChanging();
			entity.role1 = null;
		}
示例#4
0
		private void attach_roles(role entity)
		{
			this.SendPropertyChanging();
			entity.role1 = this;
		}
示例#5
0
 partial void Deleterole(role instance);
示例#6
0
 partial void Updaterole(role instance);
示例#7
0
 partial void Insertrole(role instance);
示例#8
0
        /// <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;
        }