示例#1
0
        public Reservation MakeReservation(int venueId)
        {
            Reservation finalReservation = new Reservation();
            bool        done             = false;

            while (!done)
            {
                DateTime      reserveDate     = ReserveASpaceTime();
                int           reserveDays     = ReserveASpaceDays();
                int           reserveGuests   = ReserveASpaceAttendees();
                IList <Space> availableSpaces = ListAvailableSpaces(venueId, reserveDate, reserveDays, reserveGuests);
                int           spaceId         = GetSpaceIdForReservation();
                if (spaceId == 0 || !AreRequestedDaysAvailable(spaceId, reserveDate, reserveDays) || !spaceDAO.DoesSpaceHaveOccupancy(reserveGuests, spaceId))
                {
                    done = true;
                    finalReservation.SpaceId = -1;
                    Console.WriteLine("Reservation cancelled.");
                    Console.WriteLine();
                }
                else
                {
                    string      resName = GetNameForReservation();
                    Reservation constructReservation = GatherReservationInfo(availableSpaces, spaceId, reserveDate, reserveDays, resName, reserveGuests);
                    finalReservation = resDAO.AddNewReservation(constructReservation);
                    done             = true;
                }
            }
            return(finalReservation);
        }
示例#2
0
        public void Create_Reservation_Test()
        {
            DateTime    first         = DateTime.Today;
            DateTime    last          = first.AddDays(2);
            int         originalCount = Get_Count_Of_Reservations();
            Reservation newRes        = new Reservation
            {
                //ReservationId = originalCount + 1,
                SpaceId           = 1,
                NumberOfAttendees = 5,
                StartDate         = first,
                EndDate           = last,
                ReservedFor       = "Jimmy Hoffa",
            };
            ReservationDAO dao = new ReservationDAO(connectionString);

            Reservation res = dao.AddNewReservation(newRes);

            string result = res.ReservedFor;

            Assert.AreEqual(result, "Jimmy Hoffa");
            Assert.AreEqual(originalCount + 1, Get_Count_Of_Reservations());
        }