private static void emptyTableRoom()
 {
     RoomService roomSrv = new RoomService();
     roomSrv.emptyTable();
     List<RoomBO> bookings = roomSrv.getAllFromTable();
     Assert.AreEqual(0, bookings.Count(), string.Format("'Room' Table should be empty."));
 }
        ///<remarks> 
        /// confirmation button saves the changes and returns to previous page
        /// </remarks>
        private void btnConfirmUpdateRoom_Click(object sender, RoutedEventArgs e)
        {
            RoomService roomSrv = new RoomService();
            //saving data changes
            selectedRoom.Seats = int.Parse(txtSeats.Text);
            if (inactive.IsChecked== true)
            {
                selectedRoom.Active = false;
                // Warning against existing booking in deactivated room. If room is not active, booking row in 
                // Confirmed Booking abd Unconfirmed Booking views have red background and tooltip
                MessageBoxResult inactiveRoomWarning = MessageBox.Show("Kontrolli, kas sul on deaktiveeritud ruumis broneeringuid. Broneeringute nimekirjades need on märgitud punasega", "Ruum on deaktiveeritud", MessageBoxButton.OK, MessageBoxImage.Exclamation);

            }
                else if (active.IsChecked == true)
            {
                selectedRoom.Active = true;
            }
  
            //updating object in database
            roomSrv.updateRoom(selectedRoom.RoomID, selectedRoom.Active, selectedRoom.Seats, selectedRoom.Name);

            //returning to previous page
            // Find the frame.
            Frame pageFrame = null;
            DependencyObject currParent = VisualTreeHelper.GetParent(this);
            while (currParent != null && pageFrame == null)
            {
                pageFrame = currParent as Frame;
                currParent = VisualTreeHelper.GetParent(currParent);
            }
            //goto previous page
            this.NavigationService.Navigate(new RoomsV());
        }
        public RoomsV()
        {
            InitializeComponent();
        
            RoomService roomSrv = new RoomService();
            List<RoomBO> rooms =roomSrv.getAllFromTable();
            listRooms.ItemsSource = rooms;
            _planButtons.Add(btnPlan1);
            _planButtons.Add(btnPlan2);
            _planButtons.Add(btnPlan3);
            namePlan(rooms);
            

        }
        // constructor for current logged in admin
        public ReportV(String adminName)
        {

            InitializeComponent();
            // determine last available date for period date pickers
            endDate.DisplayDateEnd = DateTime.Today.AddDays(-1);
            startDate.DisplayDateEnd = DateTime.Today.AddDays(-1);
            if (startDate.SelectedDate == null)
            {
                startDate.DisplayDate = DateTime.Today.AddDays(-1);
            }
            if (endDate.SelectedDate == null)
            {
                endDate.DisplayDate = DateTime.Today.AddDays(-1);
            }


            RoomService roomSrv = new RoomService();
            CustomerService customerSrv = new CustomerService();
            AdministratorService adminSrv = new AdministratorService();

                      
            //populate list of Customers with Customer Names from database. 
            List<CustomerBO> customers = customerSrv.getAllFromTable();
            List<String> customerNames = new List<String>();
            foreach (CustomerBO customer in customers)
            {
                String customerName = customer.CompanyName;
                customerNames.Add(customerName);
            }
            listCustomers.ItemsSource = customerNames;

            //populate comboBox of Rooms with room names from database
            List<RoomBO> rooms = roomSrv.getAllFromTable();
            List<String> roomNames = new List<String>();
            foreach (RoomBO room in rooms)
            {
                String roomName = room.Name;
                roomNames.Add(roomName);
            }
            cboxRooms.ItemsSource = roomNames;
            
        }
 /// <remarks>
 /// on Room selection prepare CustomerBO object by chosen customer name.
 /// </remarks>
 private void RoomSelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     String selectedRoomName = (String)cboxRooms.SelectedItem;
     RoomService roomSrv = new RoomService();
     _selectedRoom = (RoomBO)roomSrv.getRoomByName(selectedRoomName);
 }
        private static void fullFillTableBooking()
        {
            RoomService roomSrv = new RoomService();
            List<RoomBO> rooms = roomSrv.getAllFromTable();
            Assert.AreNotEqual(0, rooms.Count(), string.Format("There should be values in 'Rooms' Table."));
            int existingRoomID = rooms.ElementAt(0).RoomID;

            CustomerService customerSrv = new CustomerService();
            List<CustomerBO> customers = customerSrv.getAllFromTable();
            Assert.AreNotEqual(0, customers.Count(), string.Format("There should be values in 'Customer' Table."));
            int existingCustomerID = customers.ElementAt(0).CustomerID;

            AdministratorService adminSrv = new AdministratorService();
            List<AdministratorBO> admins = adminSrv.getAllFromTable();
            Assert.AreNotEqual(0, admins.Count(), string.Format("There should be values in 'Administrator' Table."));
            int existingAdminID = admins.ElementAt(0).AdminID;

            //Verify that booking cannot be created before Customer (CustomerID foreign key)
            //Verify that booking cannot be created before Room (RoomID foreign key)
            //Verify that booking cannot be created before Administrator (AdminID foreign key)
            BookingService bookingSrv = new BookingService();
            bookingSrv.addNew(DateTime.Now.AddDays(1), existingRoomID, existingCustomerID, 25, DateTime.Now, existingAdminID, "no smoking");// take first from list
            bookingSrv.addNew(DateTime.Now.AddDays(1), existingRoomID, existingCustomerID, 40, DateTime.Now, existingAdminID, "no pets allowed");
            bookingSrv.addNew(DateTime.Now.AddDays(10), existingRoomID, existingCustomerID, 77, DateTime.Now, existingAdminID, "reconfirm by phone");
            bookingSrv.addNew(DateTime.Now.AddDays(17), existingRoomID, existingCustomerID, 55, DateTime.Now, existingAdminID, "reconfirm by phone tomorrow");
            bookingSrv.addNew(DateTime.Now.AddDays(-5), existingRoomID, existingCustomerID, 10, DateTime.Now.AddDays(-8), existingAdminID, "catering ");
            bookingSrv.addNew(DateTime.Now.AddDays(-2), existingRoomID, existingCustomerID, 100, DateTime.Now.AddDays(-5), existingAdminID, "no catering");
            List<BookingBO> bookings = bookingSrv.getAllFromTable();
            Assert.AreNotEqual(0, bookings.Count(), string.Format("There should be values in 'Booking' Table."));
        }
 private static void fullFillTableRoom()
 {
     RoomService roomSrv = new RoomService();
     roomSrv.addNew("Saturn", 130, true);//TODO: take first from list
     roomSrv.addNew("Marss", 30, false);
     roomSrv.addNew("Merkuur", 55, true);
     List<RoomBO> rooms = roomSrv.getAllFromTable();
     Assert.AreNotEqual(0, rooms.Count(), string.Format("There should be values in 'Rooms' Table."));
 }