示例#1
0
        /*************************************************************************
         * Create and Delete methods
         *************************************************************************/
        /// <summary>
        /// Creates a new role
        /// </summary>
        public override void CreateRole(string roleName)
        {
            // No need to add if it already exists
            if (!RoleExists(roleName))
            {
                var r = new RoleInfo { RoleName = roleName, LoweredRolename = roleName.ToLower(), Description = roleName };

                BusinessUtil.AddRole(r);

            }
        }
示例#2
0
        /// <summary>
        /// public RoleProvider.CreateRoleFullInfo
        /// </summary>
        /// <param name="roleName"></param>
        /// <param name="roleDescription"></param>
        /// <param name="roleId"></param>
        /// <returns></returns>
        public bool CreateRoleFullInfo(string roleName, string roleDescription, int roleId)
        {
            if (roleName.Contains(","))
            {
                throw new ArgumentException("Role names cannot contain commas.");
            }

            if (RoleExists(roleName))
            {
                throw new ProviderException("Role name already exists.");
            }
            var r = new RoleInfo {Id = roleId, RoleName = roleName, LoweredRolename = roleName.ToLower() , Description = roleDescription};

            BusinessUtil.AddRole(r);

            return true;
        }
示例#3
0
 public static void AddRole(RoleInfo roleInfo)
 {
     IRoles dal = Snitz.Membership.Helpers.Factory<IRoles>.Create("Role");
     dal.CreateRole(roleInfo);
 }
示例#4
0
        public void CreateRole(RoleInfo role)
        {
            if (!RoleExists(role.RoleName))
            {
                const string strSql = "INSERT INTO snitz_Roles (ApplicationId,RoleName, LoweredRoleName,Description,RoleId) VALUES (@AppId,@Name,@LoweredName,@Description,@RoleId)";
                List<SqlParameter> parms = new List<SqlParameter>
                    {
                        new SqlParameter("@AppId", SqlDbType.VarChar){Value= new Guid().ToString()},
                        new SqlParameter("@Name", SqlDbType.VarChar){Value=role.RoleName},
                        new SqlParameter("@LoweredName", SqlDbType.VarChar){Value=role.LoweredRolename},
                        new SqlParameter("@Description", SqlDbType.VarChar){Value=role.Description},
                        new SqlParameter("@RoleId", SqlDbType.Int){Value=role.Id}
                    };
                SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql, parms.ToArray());

            }
        }
示例#5
0
 public RoleInfo GetRole(string rolename)
 {
     const string strSql = "SELECT RoleId,RoleName,Description FROM snitz_Roles WHERE RoleName=@RoleName";
     RoleInfo role = null;
     using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnString, CommandType.Text, strSql, new SqlParameter("@RoleName", SqlDbType.VarChar) { Value = rolename }))
     {
         while (rdr.Read())
         {
             role = new RoleInfo
             {
                 Id = rdr.GetInt32(0),
                 RoleName = rdr.GetString(1),
                 Description = rdr.GetString(2)
             };
         }
     }
     return role;
 }
示例#6
0
 public RoleInfo GetRole(int roleid)
 {
     const string strSql = "SELECT RoleId,RoleName,Description FROM snitz_Roles WHERE RoleId=@Roleid";
     RoleInfo role = null;
     using (var rdr = SqlHelper.ExecuteReader(SqlHelper.ConnString, CommandType.Text, strSql, new OleDbParameter("@Roleid", SqlDbType.Int) { Value = roleid }))
     {
         while (rdr.Read())
         {
             role = new RoleInfo
                    {
                        Id = rdr.GetInt32(0),
                        RoleName = rdr.GetString(1),
                        Description = rdr.GetString(2)
                    };
         }
     }
     return role;
 }