/************************************************************************* * 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); } }
/// <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; }
public static void AddRole(RoleInfo roleInfo) { IRoles dal = Snitz.Membership.Helpers.Factory<IRoles>.Create("Role"); dal.CreateRole(roleInfo); }
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()); } }
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; }
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; }