예제 #1
0
        public void ReservationConfirmationForPark(string arrivalDate, string departureDate, int camp_id, int parkSelection)
        {
            SiteSqlDAL        site            = new SiteSqlDAL(databaseconnectionString);
            ReservationSqlDAL bookReservation = new ReservationSqlDAL(databaseconnectionString);

            Console.WriteLine();
            Console.Write("Which campground should be reserved? (enter 0 to cancel)  ");
            int campInput = CLI_Helper.GetInteger("==>");

            if (campInput == 0)
            {
                return;
            }

            Console.WriteLine();
            Console.Write("Which camp site should be reserved? (enter 0 to cancel)   ");
            int siteInput = CLI_Helper.GetInteger("==>");

            if (siteInput == 0)
            {
                return;
            }

            Console.WriteLine();
            Console.Write("Under what name should the reservation be held?  ");
            string inputName = Console.ReadLine();

            bookReservation.MakeReservation(parkSelection, site.GetSiteID(siteInput, camp_id), inputName, arrivalDate, departureDate);
            string reservationID = bookReservation.GetReservationId(inputName);

            Thread.Sleep(2000);
            Console.WriteLine();
            Console.WriteLine($"The reservation has been booked and the confirmation ID is: {reservationID}");
            Console.ReadLine();
        }
예제 #2
0
        public void MakeNewReservation(string name, int campsiteId, DateTime arrivalDate, DateTime departureDate)
        {
            ReservationSqlDAL reservationSqlDAl = new ReservationSqlDAL();
            int reservationId = reservationSqlDAl.MakeReservation(name, campsiteId, arrivalDate, departureDate);

            Console.WriteLine("The reservation has been made and the confirmation id is {0}", reservationId);
        }
예제 #3
0
        /// <summary>
        /// In the makeAreservation method we again use the cli helper to take in user input.
        /// It calls the MakeReservation method from the ReservationSqlDAL class and uses it in a list
        /// We created variables of type string in and dateTime to store the user input then we called the reservation class
        /// from the models folder and assigned the user input to the variables in the reservation class which are get; set; properties
        /// We then call the list in a  if statement again and if count of items in list is > 0 we then print out the response with the
        /// reservation id confirming their reservation has been created.
        /// </summary>
        private void MakeAreservation()
        {
            string   name      = CLIHelper.GetString("Please enter the reservation name: ");
            int      site_id   = CLIHelper.GetInteger("Please enter the site number: ");
            DateTime startDate = CLIHelper.GetDateTime("Please enter the arrival date(YYYY/MM/DD): ");
            DateTime endDate   = CLIHelper.GetDateTime("Please enter the departure date(YYYY/MM/DD): ");


            Reservation newRes = new Reservation()
            {
                Name       = name,
                SiteID     = site_id,
                FromDate   = startDate,
                ToDate     = endDate,
                CreateDate = DateTime.Now
            };

            ReservationSqlDAL  dal     = new ReservationSqlDAL(DatabaseConnection);
            List <Reservation> confirm = dal.MakeReservation(newRes);

            if (confirm.Count > 0)
            {
                Console.WriteLine();
                Console.WriteLine("The reservation has been made and the confirmation ID is: " + confirm[0].ReservationId);
            }
            else
            {
                Console.WriteLine("DID NOT MAKE RESERVATION");
            }
        }
        public void MakeReservationTest()
        {
            int               result;
            string            name              = "Alec2";
            int               campsiteId        = 37;
            DateTime          arrivalDate       = DateTime.Parse("2019-07-04");
            DateTime          departureDate     = DateTime.Parse("2019-07-24");
            ReservationSqlDAL reservationSqlDAL = new ReservationSqlDAL();

            result = reservationSqlDAL.MakeReservation(name, campsiteId, arrivalDate, departureDate);
            Assert.AreEqual(testInsert + 1, result);
        }
예제 #5
0
        private void GetCampsite()
        {
            selectingReservation = true;

            while (selectingReservation)
            {
                Console.WriteLine("Please enter the Campground ID to view the list of available campsites");
                int input = Convert.ToInt32(Console.ReadLine());

                Console.WriteLine("\nWhat date would you like to begin your trip?(Please use format: mm/dd/yyyy)");
                DateTime fromDate = Convert.ToDateTime(Console.ReadLine());

                Console.WriteLine("\nWhat date would you like to end your trip?(Please use format: mm/dd/yyyy)");
                DateTime toDate = Convert.ToDateTime(Console.ReadLine());

                CampsiteSqlDAL  dal       = new CampsiteSqlDAL(DatabaseConnection);
                List <Campsite> campsites = dal.GetCampsite(input, fromDate, toDate);



                if (campsites.Count > 0)
                {
                    campsites.ForEach(c =>
                    {
                        Console.WriteLine(c);
                    });

                    Console.WriteLine("\nPlease select the ID of the site you would like to reserve. If none, select '0'.");
                    int reservationSelection = Convert.ToInt32(Console.ReadLine());

                    if (reservationSelection == 0)
                    {
                        return;
                    }

                    Console.WriteLine("\nWhat name would you like to place the reservation under?");
                    string reservationName = Console.ReadLine();

                    ReservationSqlDAL resDAL = new ReservationSqlDAL(DatabaseConnection);
                    resDAL.MakeReservation(reservationSelection, fromDate, toDate, reservationName);


                    Console.WriteLine("\nConfirmation Code: " + randomHex());


                    selectingReservation = false;
                }
                else
                {
                    Console.WriteLine("\nNo site available.\n");
                }
            }
        }
예제 #6
0
        public void MakeReservationTest()
        {
            //Arrange
            ReservationSqlDAL dal = new ReservationSqlDAL(connectionString);

            //Act
            dal.MakeReservation(1, Convert.ToDateTime("05/22/2016"), Convert.ToDateTime("05/25/2016"), "Crespo");

            List <Reservation> list = dal.GetReservation();

            //Assert
            Assert.AreEqual(2, list.Count());
            Assert.AreEqual("Crespo", list[1].name);
        }
예제 #7
0
        private void MakeReservation()
        {
            int resSpaceId = CLIHelper.GetInteger("Please enter the ID of the space you would like to reserve:");

            Console.WriteLine();
            DateTime startDates = CLIHelper.GetDateTime("When do you need the space from ? (MM/DD/YYYY)");

            Console.WriteLine();
            DateTime endDates = CLIHelper.GetDateTime("When do you need the space until ? (MM/DD/YYYY)");

            Console.WriteLine();
            int numOfPeople = CLIHelper.GetInteger("How many people will be in attendance? ");

            Console.WriteLine();
            string reserved_for = CLIHelper.GetString("Please enter the name of person or group reserving the space: ");

            Console.WriteLine();
            Console.WriteLine();
            Reservation newRes = new Reservation
            {
                spaceId     = resSpaceId,
                startDate   = startDates,
                endDate     = endDates,
                reservedFor = reserved_for
            };
            int dal = reservationDAL.MakeReservation(resSpaceId, startDates, endDates, reserved_for);

            if (dal > 0)
            {
                Space space = spaceDAL.GetASpaceName(resSpaceId);
                Venue venue = venueDAL.GetVenueNameGivenSpaceId(resSpaceId);
                Console.WriteLine(String.Format("{0, -15}", "Thanks for submitting your reservation! The details for your event are listed below: "));
                Console.WriteLine();
                Console.WriteLine("Confirmation #: " + RandomString(resSpaceId));
                Console.WriteLine("Venue: " + venue.name);
                Console.WriteLine("Space: " + space.name);
                Console.WriteLine("Reserved For: " + reserved_for);
                Console.WriteLine("Attendees: " + numOfPeople);
                Console.WriteLine("Arrival Date: " + Convert.ToDateTime(startDates));
                Console.WriteLine("Departure Date: " + Convert.ToDateTime(endDates));
                Console.WriteLine("Total Cost: $" + space.dailyRate);
            }
            else
            {
                Console.WriteLine("*** DID NOT CREATE ***");
            }
        }
예제 #8
0
        private void CompleteReservation()
        {
            int selectedSiteId = CLIHelper.GetSiteInteger("   Which campsite would you like to reserve? ", connectionString, selectedCampgroundId, desiredStartDate, desiredEndDate);

            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.Write("\n   What name should the reservation be saved under? ");
            Console.ForegroundColor = ConsoleColor.White;
            string reservationName = Console.ReadLine();

            Console.WriteLine();
            ReservationSqlDAL reservationDal = new ReservationSqlDAL(connectionString);

            reservationDal.MakeReservation(selectedSiteId, reservationName, desiredStartDate, desiredEndDate);
            Reservation thisReservation = reservationDal.GetSpecificReservation(selectedSiteId, reservationName);

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine($"   Thank You! Your reservation has been made! Your confirmation number is: {thisReservation.Reservation_Id}");
            Console.ForegroundColor = ConsoleColor.White;
        }
        // Called after viewing a list of available (unreserved) sites. Prompts the user to select a which available
        // campsite they'd like to make a reservation for. Prompts the user to give a name for the reservation. Attempts
        // to create the reservation and update the database. If successful, it will give return their reservation
        // ID as confirmation
        public void ConfirmReservation(int campgroundSelection, DateTime arrivalDate, DateTime departureDate)
        {
            Console.WriteLine("Which site should be reserved (0 to cancel)?");
            int siteSelection = int.Parse(Console.ReadLine());

            if (siteSelection == 0)
            {
                ViewAvailableParks();
            }
            else
            {
                Console.WriteLine("What name should the reservation be made under?");
                string reservationName = Console.ReadLine();

                ReservationSqlDAL myDAL          = new ReservationSqlDAL(databaseConnectionString);
                Reservation       newReservation = new Reservation();


                myDAL.MakeReservation(siteSelection, reservationName, arrivalDate, departureDate);
            }
        }
        private void MakeReservation()
        {
            List <Site> availableSites = new List <Site>();
            int         campgroundId   = CLIHelper.GetInteger("Which campground (ID number) would you like to reserve? Enter (0) to cancel.");

            if (campgroundId == 0)
            {
                return;
            }

            DateTime desiredStartDate = CLIHelper.GetDateTime("What is your desired arrival date? (__/__/____)");
            DateTime desiredEndDate   = CLIHelper.GetDateTime("What is your desired departure date? (__/__/____)");

            SiteSqlDAL  dal   = new SiteSqlDAL(DatabaseConnection);
            List <Site> sites = dal.SearchReservation(campgroundId, desiredStartDate, desiredEndDate);

            decimal totalFee = dal.GetFee(campgroundId, desiredStartDate, desiredEndDate);

            if (sites.Count > 0)
            {
                Console.WriteLine("Results Matching Your Search Criteria");
                Console.WriteLine("Site No.".PadRight(10) + "Max. Occup.".PadRight(15) + "Accessible?".PadRight(15) + "Max. RV Length".PadRight(15) + "Utility".PadRight(15) + "Cost");

                sites.ForEach(s =>
                {
                    Console.WriteLine(s + "    $" + Math.Round(totalFee, 2));
                });
            }
            else
            {
                Console.WriteLine("**** NO RESULTS ****");
                return;
            }

            int siteNumber = CLIHelper.GetInteger("Which site would you like to reserve? (Enter 0 to cancel)");

            //check out this fancy Linq thing that totally duplicates the commented-out stuff below
            int?tempSiteID = sites.First(s => s.SiteNumber == siteNumber)?.SiteID;

            //sites.ForEach(s =>
            //{
            //    if (s.SiteNumber == siteNumber)
            //    {
            //        tempSiteID = s.SiteID;
            //    }
            //});

            if (siteNumber == 0)
            {
                return;
            }

            string reservationName = CLIHelper.GetString("What name should the reservation be made under?");

            ReservationSqlDAL res = new ReservationSqlDAL(DatabaseConnection);
            bool result           = res.MakeReservation(reservationName, tempSiteID, desiredStartDate, desiredEndDate);

            if (result)
            {
                Console.WriteLine($"Your reservation has been created under the name {reservationName}.");
            }
            else
            {
                Console.WriteLine("Error. Reservation not created. Please try again.");
            }
        }
예제 #11
0
        private int BookIt(Site site, string name)
        {
            ReservationSqlDAL reservationDAL = new ReservationSqlDAL(DatabaseConnectionString);

            return(reservationDAL.MakeReservation(this.reservation));
        }