Exemplo n.º 1
0
        private void PrintAvailableSitesList()
        {
            int desiredNumberOfDays = (desiredEndDate.Date - desiredStartDate.Date).Days + 1;

            SiteSqlDAL  siteDal = new SiteSqlDAL(connectionString);
            List <Site> sites   = siteDal.GetListOfTop5AvailableSitesAtCampground(selectedCampgroundId, desiredStartDate, desiredEndDate);

            if (sites.Count == 0)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("   There are NO campsites available on your desired dates. Would you like to:\n");
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("   1 - Select a new park");
                Console.WriteLine("   2 - Enter new search criteria");
                Console.WriteLine("   3 - Return to the Main Menu\n");
                int noSitesChoice = CLIHelper.GetSubMenuInteger("   Selection: ");

                if (noSitesChoice == 1)
                {
                    Console.Clear();
                    PrintParkList();
                    SelectAPark();
                    Console.Clear();
                    PrintCampgroundList();
                    PromptForSiteSearchCriteria();
                    Console.Clear();
                    PrintAvailableSitesList();
                }
                else if (noSitesChoice == 2)
                {
                    Console.Clear();
                    PrintCampgroundList();
                    PromptForSiteSearchCriteria();
                    Console.Clear();
                    PrintAvailableSitesList();
                }
            }
            else
            {
                CampgroundSqlDAL campgroundDal      = new CampgroundSqlDAL(connectionString);
                Campground       selectedCampground = campgroundDal.GetSelectedCampground(selectedCampgroundId);

                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine($"   Campsites available at {selectedCampground.Name}   \n");
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("   Site No.".PadRight(15)
                                  + "Max Occup.".PadRight(14)
                                  + "Accessible?".PadRight(15)
                                  + "Max RV Length".PadRight(17)
                                  + "Utility".PadRight(11)
                                  + "Cost ".PadLeft(9));

                foreach (Site site in sites)
                {
                    string accessibleYesOrNo  = "";
                    string maxRVLengthNumOrNA = "";
                    string utilitiesYesOrNA   = "";

                    if (site.Accessible)
                    {
                        accessibleYesOrNo = "Yes";
                    }
                    else
                    {
                        accessibleYesOrNo = "No";
                    }
                    if (site.Max_RV_Length == 0)
                    {
                        maxRVLengthNumOrNA = "N/A";
                    }
                    else
                    {
                        maxRVLengthNumOrNA = site.Max_RV_Length.ToString();
                    }
                    if (site.Utilities)
                    {
                        utilitiesYesOrNA = "Yes";
                    }
                    else
                    {
                        utilitiesYesOrNA = "N/A";
                    }

                    Console.WriteLine("      " + site.Site_Id.ToString().PadRight(9)
                                      + "    " + site.Max_Occupancy.ToString().PadRight(10)
                                      + "    " + accessibleYesOrNo.PadRight(11)
                                      + "    " + maxRVLengthNumOrNA.PadRight(13)
                                      + "  " + utilitiesYesOrNA.PadRight(9)
                                      + ("$" + Math.Round((desiredNumberOfDays * selectedCampground.Daily_Fee), 2)).PadLeft(9));
                }
            }
            Console.WriteLine();
        }