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