davidfowl/JabbR — pull request #303 by PureKrome (2012-01-14 06:42:51+00:00)
Title: Issue#190 - Close a room

So I've given this a crack.

new command:

/close

A room now has a new property => `bool IsOpen`. My migration (`201201130555046_RoomIsOpen.cs`) hopefully sets it by default (mainly for existing rooms) to TRUE .. meaning all rooms are open, initially. By default new rooms created are also open.

```c#
public ChatRoom()
{
....
IsOpen = true;
}
```

Closing a room just sets the property `IsOpen = false` and then i persist it to the store.

Two of the important structural changes have been

```c#
IJabbrRepo

ChatRoom GetRoomByNameAndIsOpen(string roomName, bool isOpen);
```
So it will retrieve a room by name AND the IsOpen status.

```c#
ChatRoom GetRoomByName(string roomName);
```
that remains untouched, still.

Next, the `VerifyRoom` has been changed to this...

```c#
public static ChatRoom VerifyRoom(this IJabbrRepository repository, string roomName)
{
return VerifyRoom(repository, roomName, true);
}

public static ChatRoom VerifyRoom(this IJabbrRepository repository, string roomName, bool? isOpen)
{ ... }
````

So this means the code is backwards compatible AND all existing code therefore requires a room to exist, etc.. BUT also be Open (ie. the IsOpen == true, in the third paramater, above).

That's really about it :)

Looking forward to seeing what you gents think.

OH! I'll need to create a new issue, after this. a /reopen command .. to open an existing closed room. (unless u want ADMIN to do that, for the once in a million times that's required.

A few side notes:-

1. You cannot close a room if there's people in it.
2. A room can only be closed by a person who is an owner. Remember, rooms can have multiple owners, which fine :)
3. The room is not shown in the Lobby if it's closed. It still exists in the DB.
4. Trying to join a closed room == 'Unable to find room 'qwerty''