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