public static Character GetCharacter(string characterName) { IDbDataParameter parameter = WebSite.Database.CreateParameter("@Name", characterName); DataTable table = WebSite.Database.ExecuteQuery("SELECT * FROM characters WHERE Name=@Name", parameter); if (table == null) { return(null); } if (table.Rows.Count < 1) { return(null); } DataRow dataRow = table.Rows[0]; return(CharacterHelper.FromDataRow(dataRow)); }
public static Character GetCharacter(int id) { if (id == -1) { return(null); } IDbDataParameter parameter = WebSite.Database.CreateParameter("@ID", id); DataTable table = WebSite.Database.ExecuteQuery("SELECT * FROM characters WHERE Id=@ID", parameter); if (table == null) { return(null); } if (table.Rows.Count < 1) { return(null); } DataRow dataRow = table.Rows[0]; return(CharacterHelper.FromDataRow(dataRow)); }
public static Character[] GetCharacters(User user) { IDbDataParameter parameter = WebSite.Database.CreateParameter("@UserId", user.Id); DataTable table = WebSite.Database.ExecuteQuery("SELECT * FROM characters WHERE UserId=@UserId", parameter); if (table == null) { return(new Character[0]); } if (table.Rows.Count < 1) { return(new Character[0]); } List <Character> characters = new List <Character>(); foreach (DataRow row in table.Rows) { characters.Add(CharacterHelper.FromDataRow(row)); } return(characters.ToArray()); }