Ejemplo n.º 1
0
        public void TestSetTime_True()
        {
            DateTime startTime = new DateTime(2000, 1, 1, 12, 00, 00);
            DateTime endTime = new DateTime(2001, 1, 1, 15, 00, 00);

            Booking booking = new Booking();

            bool result = booking.SetTime(startTime, endTime);
            Assert.AreEqual(startTime, booking.StartTime);
            Assert.AreEqual(endTime, booking.EndTime);

            Assert.IsTrue(result);
        }
Ejemplo n.º 2
0
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            switch (createEdit.ToUpper())
            {
                case "CREATE":
                    Booking booking = new Booking();
                    if (!booking.SetTime(Convert.ToDateTime(StartTimePicker.Text), Convert.ToDateTime(EndTimeTextBox.Text)))
                    {
                        Xceed.Wpf.Toolkit.MessageBox.Show("Sluttidspunktet skal være senere end starttidspunktet.");
                        return;
                    }
                    booking.Room = roomCrud.Read(Convert.ToInt32(ConferenceRoomIdTextBox.Text));
                    booking.Customer = cusCrud.Read(CustomerCVRTextBox.Text);
                    booking.Employee = empCrud.Read(Convert.ToInt32(EmployeeIdTextBox.Text));
                    booking.Price = Convert.ToDouble(PriceTextBox.Text);
                    bookingCrud.Create(booking);
                    Bookings.Add(booking);
                    break;
                case "EDIT":
                    booking = Booking;
                    if (!booking.SetTime(Convert.ToDateTime(StartTimePicker.Text), Convert.ToDateTime(EndTimeTextBox.Text)))
                    {
                        Xceed.Wpf.Toolkit.MessageBox.Show("Sluttidspunktet skal være senere end starttidspunktet.");
                        return;
                    }
                    booking.Room = roomCrud.Read(Convert.ToInt32(ConferenceRoomIdTextBox.Text));
                    booking.Customer = cusCrud.Read(CustomerCVRTextBox.Text);
                    booking.Employee = empCrud.Read(Convert.ToInt32(EmployeeIdTextBox.Text));
                    booking.Price = Convert.ToDouble(PriceTextBox.Text);
                    bookingCrud.Update(booking);

                    break;
            }

            Close();
        }
Ejemplo n.º 3
0
        public override IEnumerable<Booking> Read()
        {
            var rows = DBConnection.ExecuteQuery("SELECT Id, StartTime, EndTime, ConferenceRoomId, EmployeeId, CustomerCVR, Price FROM Booking;");
            var bookings = new List<Booking>();

            foreach (var row in rows)
            {
                Booking b = new Booking
                {
                    Id = Convert.ToInt32(row.ElementAt(0)),
                    Price = Convert.ToDouble(row.ElementAt(6))
                };
                b.Room = RoomCrud.Read(b);
                b.Employee = EmployeeCrud.Read(b);
                b.Customer = CustomerCrud.Read(b);
                DateTime StartTime = Convert.ToDateTime(row.ElementAt(1).ToString());
                DateTime EndTime = Convert.ToDateTime(row.ElementAt(2).ToString());
                b.SetTime(StartTime, EndTime);
                bookings.Add(b);
            }
            return bookings;
        }
Ejemplo n.º 4
0
        public override Booking Read(int key)
        {
            var booking = DBConnection.ExecuteQuery($"SELECT Id, StartTime, EndTime, ConferenceRoomId, EmployeeId, CustomerCVR, Price FROM Booking WHERE Id={key};").First();

            Booking b = new Booking
            {
                Id = Convert.ToInt32(booking.ElementAt(0)),
                Price = Convert.ToDouble(booking.ElementAt(6))
            };

            b.Room = RoomCrud.Read(b);
            b.Employee = EmployeeCrud.Read(b);
            b.Customer = CustomerCrud.Read(b);
            b.SetTime(Convert.ToDateTime(booking.ElementAt(1).ToString()), Convert.ToDateTime(booking.ElementAt(2).ToString()));
            return b;
        }