Esempio n. 1
0
        /// <summary>
        /// Returns the room based on the name, a new room if it doesn't exist, or null if the password is wrong
        /// </summary>
        /// <param name="roomName"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public static Room GetRoom(string roomName, string password)
        {
            var mongoRepository = new MongoRepository<Room>(ConnectionString);

            Room room = mongoRepository.SingleOrDefault(r => r.Name == roomName);
            if (room == null)
            {
                room = new Room { Name = roomName, Password = password, DateCreated = DateTime.Now };
            }
            else if (room.Password != password)
            {
                room = null;
            }

            return room;
        }
Esempio n. 2
0
 public static void DeleteRoom(Room room)
 {
     var mongoRepository = new MongoRepository<Room>(ConnectionString);
     mongoRepository.Delete(room);
 }
Esempio n. 3
0
 public static bool SaveRoom(Room room)
 {
     if (VerifyRoom(room))
     {
         var mongoRepository = new MongoRepository<Room>(ConnectionString);
         mongoRepository.Save(room);
         return true;
     }
     return false;
 }
Esempio n. 4
0
 private static bool VerifyRoom(Room room)
 {
     return !String.IsNullOrEmpty(room.Name);
 }
Esempio n. 5
0
 public void AddRoom(Room room)
 {
     _clients.AddRoom(room);
 }