Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }