//Returnerar en tjänst med lediga tider som användaren ofta nyttjar.
        public async Task <Service> GetServiceSuggestion(BookingSystem bookingSystem)
        {
            List <int> mostBookings      = new List <int>();
            Service    serviceSuggestion = new Service();

            if (bookingSystem.Services.Count > 0)
            {
                foreach (var service in bookingSystem.Services)
                {
                    if (service.Bookings.Count > 0)
                    {
                        //Räknar antal bokningar
                        var numberOfTimes = service.Bookings.Count();
                        mostBookings.Add(numberOfTimes);
                    }
                }

                /*Tilldelar variabeln värdet på tjänsten från ett bokningssystem med flest antal
                 * bokningar som användaren har gjort*/
                serviceSuggestion = bookingSystem.Services.
                                    Where(x => x.Bookings.Count == mostBookings.Max()).
                                    First();
            }
            return(await Task.FromResult(serviceSuggestion));
        }
 public void SetUp()
 {
     TourScheduleStub = new TourScheduleStub();
     sut           = new BookingSystem(TourScheduleStub);
     PassengerStub = new Passenger()
     {
         Fname = "Emil",
         Lname = "Fagerberg"
     };
 }
        public void SetUp()
        {
            scheduleStub = new TourScheduleStub();
            sut          = new BookingSystem(scheduleStub);

            passenger = new Passenger
            {
                FirstName = "John",
                LastName  = "Doe",
            };
        }
Esempio n. 4
0
        protected void OnFinishButtonClick(object sender, WizardNavigationEventArgs e)
        {
            BookingSystem bs          = new BookingSystem();
            Appointment   appointment = new Appointment();

            //Set current user values
            appointment.username = this.User.Identity.Name;
            MembershipUser user = Membership.GetUser(appointment.username);

            if (user != null)
            {
                appointment.email = user.Email;
            }
            Int32    BookingObjectId = Convert.ToInt32(Session["bookingObject"]);
            DateTime StartTime       = Calendar1.SelectedDate.Date.Add(TimeSpan.Parse(startTimeDDL.SelectedItem.Text));

            //Set form values
            appointment.bookingObject = BookingObjectId;
            appointment.startDate     = StartTime;
            appointment.endDate       = appointment.startDate.Add(bs.AppointmentLength);
            appointment.comments      = Comments.Text;

            Int32 rowReturned = 0;

            DataTable days           = bs.GetBookingObjectWorkingDays(BookingObjectId);
            DataTable BookingObjects = bs.GetBookingObjects(BookingObjectId);
            DataRow   row            = BookingObjects.Rows[0];
            DateTime  openTime       = DateTime.Parse(row["StartTime"].ToString());
            DateTime  closeTime      = DateTime.Parse(row["EndTime"].ToString());


            //Check to See Room is open
            if (!bs.RoomClosed(BookingObjectId, StartTime, openTime.TimeOfDay,
                               closeTime.TimeOfDay, days))
            {
                //Check for Existing Booking
                if (bs.RoomBooked(appointment.bookingObject, appointment.startDate))
                {
                    rowReturned = bs.AddAppointment(appointment);
                }
            }

            if (rowReturned == 1)
            {
                Error.Text = "Appointment Succesfully Added.";
            }
            else
            {
                Error.Text = "Error adding row.";
            }
        }
Esempio n. 5
0
        public void GetAvailableRooms_valid_handicap_pets()
        {
            DateTime   START_DATE            = DateTime.MinValue;
            DateTime   END_DATE              = DateTime.MaxValue;
            const bool WILL_REQUIRE_HANDICAP = true;
            const bool WILL_REQUIRE_PETS     = true;

            IBookingSystem b = new BookingSystem();

            var result = b.GetAvailableRooms(START_DATE, END_DATE, WILL_REQUIRE_HANDICAP, WILL_REQUIRE_PETS);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count > 0);
        }
Esempio n. 6
0
        protected void OnFinishButtonClick(object sender, WizardNavigationEventArgs e)
        {
            BookingSystem bs = new BookingSystem();
                                    Appointment appointment = new Appointment();

                                    //Set current user values
                                    appointment.username = this.User.Identity.Name;
                                    MembershipUser user = Membership.GetUser(appointment.username);
                                    if (user != null)
                                    {
                                                appointment.email = user.Email;
                                    }
                                    Int32 BookingObjectId = Convert.ToInt32(Session["bookingObject"]);
                                    DateTime StartTime = Calendar1.SelectedDate.Date.Add(TimeSpan.Parse(startTimeDDL.SelectedItem.Text));
                                    //Set form values
                                    appointment.bookingObject = BookingObjectId;
                                    appointment.startDate = StartTime;
                                    appointment.endDate = appointment.startDate.Add(bs.AppointmentLength);
                                    appointment.comments = Comments.Text;

                                    Int32 rowReturned = 0;

                                    DataTable days = bs.GetBookingObjectWorkingDays(BookingObjectId);
                                    DataTable BookingObjects = bs.GetBookingObjects(BookingObjectId);
                                    DataRow row = BookingObjects.Rows[0];
                                    DateTime openTime = DateTime.Parse(row["StartTime"].ToString());
                                    DateTime closeTime = DateTime.Parse(row["EndTime"].ToString());

                                    //Check to See Room is open
                                    if (!bs.RoomClosed(BookingObjectId, StartTime, openTime.TimeOfDay,
                                                closeTime.TimeOfDay, days))
                                    {
                                                //Check for Existing Booking
                                                if (bs.RoomBooked(appointment.bookingObject, appointment.startDate))
                                                {
                                                            rowReturned = bs.AddAppointment(appointment);
                                                }
                                    }

                                    if (rowReturned == 1)
                                    {
                                                Error.Text = "Appointment Succesfully Added.";
                                    } else {
                                                Error.Text = "Error adding row.";
                                    }
        }
Esempio n. 7
0
        public void GetAvailableRooms_invalid_start_Date()
        {
            DateTime   START_DATE            = DateTime.MaxValue;
            DateTime   END_DATE              = DateTime.MinValue;
            const bool WILL_REQUIRE_HANDICAP = false;
            const bool WILL_REQUIRE_PETS     = false;


            IBookingSystem b = new BookingSystem();

            try
            {
                var result = b.GetAvailableRooms(START_DATE, END_DATE, WILL_REQUIRE_HANDICAP, WILL_REQUIRE_PETS);
            }
            catch (ArgumentException ex)
            {
                Assert.IsTrue(ex.Message.Contains("Start date must precede the end date."));
            }
        }
Esempio n. 8
0
        public void MakeReservationTest()
        {
            //Arrange
            BookingSystem testObj = new BookingSystem(connectionString);
            Reservation   result;
            int           newId = 0;

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                conn.Open();

                string sqlInsertVenue        = "INSERT INTO space (name, is_accessible, venue_id, daily_rate, max_occupancy) VALUES ('ZZZZ', 1, 1, 600.00, 150)";
                string sqlGetInsertedVenueID = "SELECT id FROM space WHERE name = 'ZZZZ'";

                SqlCommand cmd   = new SqlCommand(sqlInsertVenue, conn);
                int        count = cmd.ExecuteNonQuery();

                cmd = new SqlCommand(sqlGetInsertedVenueID, conn);
                SqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    newId = Convert.ToInt32(reader["id"]);
                }
                reader.Close();
            }

            List <Space> spaces = new List <Space>();
            Space        temp   = new Space(newId, "ZZZZ", 600M, 150, true);

            spaces.Add(temp);
            DateTime tempDate = new DateTime(2020, 1, 1);

            //Act
            result = testObj.MakeReservation(spaces, newId, 100, tempDate, 1, "Hidden Owl Eatery", "TestRes");

            //Assert
            Assert.IsNotNull(result);
            Assert.IsNotNull(result.ReservationID);
        }
Esempio n. 9
0
        public void Reservation_Create_no_handicap_two_pets_single_room_Pass()
        {
            const int    PET_COUNT      = 2;
            const int    HANDICAP_COUNT = 0;
            const double EXPECTED_COST  = 490; //Assume 10 day stay.
            const int    RESERVATION_ID = 1;

            //prepare the test data.

            var room = new Room();

            room.BedCount   = 1;
            room.Level      = 1;
            room.RoomNumber = 111;

            //prepare the test data.
            var g = new Guest();

            g.GuestID               = 1;
            g.FirstName             = "Alice";
            g.LastName              = "Smith";
            g.PetCount              = PET_COUNT;
            g.RequiredHandicapRooms = HANDICAP_COUNT;

            var r = new Reservation();

            r.ReservationID = RESERVATION_ID;
            r.StartDate     = new DateTime(2019, 1, 1);
            r.EndDate       = new DateTime(2019, 1, 10);
            r.Rooms.Add(room);

            //test the implementation.
            IBookingSystem b      = new BookingSystem();
            var            result = b.CreateReservation(g, r);

            Assert.AreEqual($"Thanks! The reservation({r.ReservationID}) was placed successfully! Your total cost was ${EXPECTED_COST.ToString("#.##")}.", result);
        }
Esempio n. 10
0
        public void Reservation_Create_one_pet_wrong_level_FAIL()
        {
            const int PET_COUNT      = 1;
            const int HANDICAP_COUNT = 0;
            const int RESERVATION_ID = 1;

            //prepare the test data.

            var room = new Room();

            room.BedCount   = 1;
            room.Level      = 2;
            room.RoomNumber = 211;

            //prepare the test data.
            var g = new Guest();

            g.GuestID               = 1;
            g.FirstName             = "Alice";
            g.LastName              = "Smith";
            g.PetCount              = PET_COUNT;
            g.RequiredHandicapRooms = HANDICAP_COUNT;

            var r = new Reservation();

            r.ReservationID = RESERVATION_ID;
            r.StartDate     = new DateTime(2019, 1, 1);
            r.EndDate       = new DateTime(2019, 1, 10);
            r.Rooms.Add(room);

            //test the implementation.
            IBookingSystem b      = new BookingSystem();
            var            result = b.CreateReservation(g, r);

            Assert.AreEqual($"Error! {g.FirstName} requires at least one pet-friendly room! Please select a room on the ground floor. The reservation was not saved.", result);
        }
Esempio n. 11
0
        public void Reservation_Create_three_pets_FAIL()
        {
            const int PET_COUNT      = 3;
            const int HANDICAP_COUNT = 0;
            const int RESERVATION_ID = 1;

            //prepare the test data.

            var room = new Room();

            room.BedCount   = 1;
            room.Level      = 1;
            room.RoomNumber = 111;

            //prepare the test data.
            var g = new Guest();

            g.GuestID               = 1;
            g.FirstName             = "Alice";
            g.LastName              = "Smith";
            g.PetCount              = PET_COUNT;
            g.RequiredHandicapRooms = HANDICAP_COUNT;

            var r = new Reservation();

            r.ReservationID = RESERVATION_ID;
            r.StartDate     = new DateTime(2019, 1, 1);
            r.EndDate       = new DateTime(2019, 1, 10);
            r.Rooms.Add(room);

            //test the implementation.
            IBookingSystem b      = new BookingSystem();
            var            result = b.CreateReservation(g, r);

            Assert.AreEqual("Sorry! According to the Motel Pet Policy, only a maximum of two pets are allowed. The reservation was not saved.", result);
        }
Esempio n. 12
0
 public BookingSystemOfInterest(BookingSystem bookingSystem, double distance)
 {
     this.bookingSystem = bookingSystem;
     this.distance      = distance;
 }
Esempio n. 13
0
 public void SetUp()
 {
     _TourScheduleStub = new TourScheduleStub();
     Sut = new BookingSystem(_TourScheduleStub);
 }
Esempio n. 14
0
 public void Setup()
 {
     tourScheduleStub = new TourScheduleStub();
     sut = new BookingSystem(tourScheduleStub);
 }
Esempio n. 15
0
 public BookingAdapter()
 {
     this.bookingSystem = new BookingSystem();
 }