public void DateRangeSubMenu(int parkID)
        {
            Console.Clear();
            Console.WriteLine("{0, -20}{1, -20}{2, -20}{3, -20}", "      Name", "      Open", "   Close", "  Daily Fee");
            PrintCampGrounds(parkID);
            Console.WriteLine();
            Console.Write($"Which Campground (enter 0 to return to main menu)?");
            string campgroundSelection = Console.ReadLine();
            int    selection           = int.Parse(campgroundSelection);
            int    resID = 0;

            if (_campgroundDictionary.ContainsKey(selection))
            {
                Campground campground = _campgroundDictionary[selection];

                Console.Write("What is your arrival date? (yyyy/mm/dd)");
                DateTime arrivalDate = DateTime.Parse(Console.ReadLine());
                Console.Write("What is your departure date? (yyyy/mm/dd)");
                DateTime          departureDate  = DateTime.Parse(Console.ReadLine());
                SiteSqlDAL        dal            = new SiteSqlDAL(DatabaseConnection);
                var               listOfSites    = dal.GetSitesInCampground(campground.Id);
                ReservationSqlDAL resDal         = new ReservationSqlDAL(DatabaseConnection);
                List <Site>       availableSites = resDal.ReturnSites(selection, arrivalDate, departureDate);
                Console.WriteLine();
                Console.WriteLine("Results matching your search criteria");
                Console.WriteLine("{0, -15}{1, -15}{2, -15}{3, -15}{4, -20}", "Site Number", "Max Occupancy", "Accesibility", "Max RV Length", "Utilities");
                foreach (var item in availableSites)
                {
                    Console.WriteLine($"{item.SiteNumber, -15}  {item.MaxOccupancy, -15}  {item.Accessible, -15}  {item.MaxRVLength, -15}  {item.Utilities, -15}");
                }
                Console.WriteLine("What site should be reserved?");
                char tempSiteRes = Console.ReadKey().KeyChar;
                Console.WriteLine();
                Console.WriteLine("What name should the reservation be made under?");
                string resName = Console.ReadLine();
                Console.ReadKey();
                bool wasSuccesful = resDal.InsertReservation(tempSiteRes, resName, arrivalDate, departureDate);
                if (wasSuccesful)
                {
                    resID = resDal.GetReservationID(tempSiteRes, resName, arrivalDate, departureDate);
                    Console.WriteLine("Your reservation number is: " + resID);
                    Console.ReadKey();
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Captures reservation inputs and stores them in the database
        /// </summary>
        /// <param name="selection"></param>
        public void ReservationSubMenu(int selection)
        {
            try
            {
                int        resID      = 0;
                Campground campground = _campgroundDictionary[selection];

                Console.Write("What is your arrival date? (yyyy-mm-dd) ");
                DateTime arrivalDate = DateTime.Parse(Console.ReadLine());
                Console.Write("What is your departure date? (yyyy-mm-dd) ");
                DateTime   departureDate = DateTime.Parse(Console.ReadLine());
                SiteSqlDAL sitedal       = new SiteSqlDAL(DatabaseConnection);
                var        listOfSites   = sitedal.GetSitesInCampground(campground.Id);
                double     dailyFee      = campground.DailyFee;
                double     totalDays     = (departureDate - arrivalDate).TotalDays;
                double     tempTotalCost = dailyFee * totalDays;
                string     totalCost     = tempTotalCost.ToString("c");

                ReservationSqlDAL resDal = new ReservationSqlDAL(DatabaseConnection);

                List <int> siteIDs = new List <int>();
                for (int i = 0; i < listOfSites.Count; i++)
                {
                    siteIDs.Add(listOfSites[i].Id);
                }
                int         campID         = campground.Id;
                List <Site> availableSites = resDal.ReturnSites(campID, arrivalDate, departureDate);
                Console.WriteLine();
                Console.WriteLine("Results matching your search criteria");
                Console.WriteLine();
                Console.WriteLine("{0, -5}{1, -20}{2, -20}{3, -20}{4, -20}", "ID", "Max Occupancy", "Accesibility", "Max RV Length", "Utilities");
                Console.WriteLine();
                int options = 0;
                foreach (var item in availableSites)
                {
                    options++;
                    Console.WriteLine($"{options,-5}{item.MaxOccupancy,-20}{item.Accessible,-20}{item.MaxRVLength,-20}{item.Utilities,-20}");
                }

                Console.WriteLine("What site should be reserved? (Please input valid ID) ");
                string tempInput = Console.ReadLine();
                int    tempIndex = int.Parse(tempInput);
                Site   siteRes   = availableSites[tempIndex - 1];
                int    siteID    = siteRes.Id;
                Console.WriteLine();
                Console.WriteLine("What name should the reservation be made under? ");
                string resName = Console.ReadLine();

                bool wasSuccesful = resDal.InsertReservation(siteID, resName, arrivalDate, departureDate);
                if (wasSuccesful)
                {
                    resID = resDal.GetReservationID(siteID, resName, arrivalDate, departureDate);
                    Console.WriteLine("Your total cost will be: " + totalCost);
                    Console.WriteLine("Your reservation number is: " + resID);
                    Console.WriteLine("Thank you!");
                    Console.ReadKey();
                }
            }
            catch
            {
                Console.WriteLine("Invalid input");
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey();
            }
        }