Esempio n. 1
0
        public MakeReservationMenu(IReservationDAO resDaoParam, Campground campground, DateTime arrival, DateTime departure)
            : base()
        {
            this.reservationDAO = resDaoParam;
            this.Campground     = campground;
            this.Arrival        = arrival;
            this.Departure      = departure;
            this.AvailableSites = reservationDAO.GetAvailableSites(arrival, departure, this.Campground.Campground_Id);

            this.Title = "Results matching your search criteria:";
            // This if statement displays a message letting the user know that no sites were found and sets
            // the "FoundReservations" property to false.
            if (this.AvailableSites.Count == 0)
            {
                this.FoundReservations = false;
                Console.WriteLine("Unfortunately, all sites at that campground are booked during your requested dates.");
                Console.WriteLine("Please select from one of our other amazing campgrounds.");
                Pause("");
            }
            else
            {
                this.FoundReservations = true;
                foreach (Site site in this.AvailableSites)
                {
                    //creates strings to hold a yes/no value for the two boolean fields
                    string accessible = site.Accessible ? "Yes" : "No";
                    string utilities  = site.Utilities ? "Yes" : "No";
                    this.menuOptions.Add(site.Site_Number.ToString("00"),
                                         $"     {site.Max_Occupancy,-14} {accessible,-15}{site.Max_Rv_Length,-15}{utilities,-9}" +
                                         $"{this.Campground.Daily_Fee * (departure - arrival).Days,7:C}");
                }
            }
            this.menuOptions.Add("Q", " ");
            Console.WriteLine();
        }