// Deletes the specified room
        public bool DeleteRoom(Room room)
        {
            Program      app          = Program.GetInstance();
            Database     database     = app.GetDatabase();
            ChairService chairService = app.GetService <ChairService>("chairs");
            ShowService  showService  = app.GetService <ShowService>("shows");

            // Find record
            RoomRecord record = database.rooms.SingleOrDefault(i => i.id == room.id);

            if (record == null)
            {
                return(false);
            }

            // Remove record and related chairs/shows
            database.rooms.Remove(record);

            foreach (Chair chair in chairService.GetChairsByRoom(room))
            {
                chairService.DeleteChair(chair);
            }

            foreach (Show show in showService.GetShowsByRoom(room))
            {
                showService.DeleteShow(show);
            }

            // Try to save
            database.TryToSave();

            return(true);
        }
        // Saves the specified room
        public bool SaveRoom(Room room)
        {
            Program      app          = Program.GetInstance();
            Database     database     = app.GetDatabase();
            ChairService chairService = app.GetService <ChairService>("chairs");
            bool         isNew        = room.id == -1;

            // Validate and add if valid
            if (!room.Validate())
            {
                return(false);
            }

            // Set id if its a new room
            if (isNew)
            {
                room.id = database.GetNewId("rooms");
            }

            // Find existing record
            RoomRecord record = database.rooms.SingleOrDefault(i => i.id == room.id);

            // Add if no record exists
            if (record == null)
            {
                record = new RoomRecord();
                database.rooms.Add(record);
            }

            // Update record
            record.id     = room.id;
            record.number = room.number;

            // Try to save
            database.TryToSave();

            return(true);
        }