public static League CreateLeagueFromDB(LeagueDB ld) { League l = new League(ld.id, ld.name); foreach (RoomDB rd in ld.Rooms) { l.Rooms.Add(RoomsByDB.CreateRoomFromDB(rd)); } return(l); }
public void RemoveRoomFromLeague(League league, Room room) { LeagueDB l = CreateLeagueDB(league); if (l == null) { return; } l.Rooms.Remove(RoomsByDB.CreateRoomDB(room)); league.Rooms.Remove(room); db.SaveChanges(); Log.InfoLog("DB:Remove Room " + room.Id + " From League " + league.Id); }
public void AddRoomToLeague(League league, Room room) { LeagueDB ldb = CreateLeagueDB(league); if (ldb.Rooms.Count != 0 && ldb.Rooms.Any(l => l.id == room.Id)) { return; } RoomDB rdb = RoomsByDB.CreateRoomDB(room); ldb.Rooms.Add(rdb); league.Rooms.Add(room); db.SaveChanges(); Log.InfoLog("DB:Add Room " + room.Id + " to a League " + league.Id); }
public static LeagueDB CreateLeagueDB(League league) { LeagueDB l; if (db.LeagueDBs.Count() != 0) { try { return(db.LeagueDBs.First(lea => lea.id == league.Id)); } catch { } } l = new LeagueDB { id = league.Id, name = league.Name }; foreach (Room r in league.Rooms) { l.Rooms.Add(RoomsByDB.CreateRoomDB(r)); } return(l); }