/// <summary> /// Inserts a new Role record in the AspNetRoles table. /// </summary> /// <param name="roleName">The role's name.</param> /// <returns></returns> public int Insert(IdentityRole role) { string commandText = "INSERT INTO \"AspNetRoles\" (\"Id\", \"Name\") VALUES (@id, @name)"; Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("@name", role.Name); parameters.Add("@id", role.Id); return _database.Execute(commandText, parameters); }
/// <summary> /// Inserts a new Role record in the AspNetRoles table. /// </summary> /// <param name="roleName">The role's name.</param> /// <returns></returns> public int Insert(IdentityRole role) { string commandText = "INSERT INTO "+fullTableName+" ("+fieldId.Quoted()+", "+fieldName.Quoted()+") VALUES (@id, @name)"; Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("@name", role.Name); parameters.Add("@id", role.Id); return _database.Execute(commandText, parameters); }
/// <summary> /// Returns all role names. /// /// Created by: Slawomir Figiel /// </summary> /// <returns>Role name.</returns> public List<IdentityRole> GetAllRoleNames() { List<IdentityRole> roles = new List<IdentityRole>(); string commandText = "SELECT * FROM \"AspNetRoles\""; var rows = _database.Query(commandText, new Dictionary<string, object>()); foreach (var row in rows) { IdentityRole r = new IdentityRole(row["Name"], row["Id"]); roles.Add(r); } return roles; }
public int Update(IdentityRole role) { string commandText = "UPDATE \"AspNetRoles\" SET \"Name\" = @name WHERE \"Id\" = @id"; Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("@id", role.Id); return _database.Execute(commandText, parameters); }
/// <summary> /// Gets the IdentityRole given the role name. /// </summary> /// <param name="roleName"></param> /// <returns></returns> public IdentityRole GetRoleByName(string roleName) { var roleId = GetRoleId(roleName); IdentityRole role = null; if (roleId != null) { role = new IdentityRole(roleName, roleId); } return role; }
public int Update(IdentityRole role) { string commandText = "UPDATE "+fullTableName+" SET "+fieldName.Quoted()+" = @name WHERE "+fieldId.Quoted()+" = @id"; Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("@id", role.Id); return _database.Execute(commandText, parameters); }