public void AddGroup(Group grp) { groups.Add(grp); groupsByMaster.Add(grp.Master.Name, grp); groupsById.Add(grp.Id, grp); updateQueue.Enqueue(grp); }
public static Group LoadGroupFromDatabaseById(long pId) { //-------------------------------------------------- // Queries used in this function //-------------------------------------------------- const string read_group_query = "USE `fiesta_world`; " + "SELECT `Id`, `Member1`, `Member2`, `Member3`, `Member4`, `Member5` " + "FROM `groups` " + "WHERE Id = {0}"; //-------------------------------------------------- // Reading the group out of the database //-------------------------------------------------- Group grp = new Group(); grp.Id = pId; using (var client = Program.DatabaseManager.GetClient()) { string query = string.Format(read_group_query, pId); using(var cmd = new MySqlCommand(query, client.GetConnection())) using(var reader = cmd.ExecuteReader()) { while(reader.Read ()) { for(int i = 1; i < 6; i++) { if(!reader.IsDBNull(i)) grp.Members.Add(ReadGroupMemberFromDatabase(reader.GetInt64(i))); } } } } return grp; }
private void UpdateGroup(Group grp) { if(!groups.Contains(grp)) return; grp.Update(); updateQueue.Enqueue(grp); }
private void RemoveGroup(Group grp) { this.groups.Remove(grp); this.groupsByMaster.Remove(grp.Master.Name); this.groupsById.Remove(grp.Id); }