コード例 #1
0
ファイル: ProjectCLI.cs プロジェクト: jacobbulicek/TEProjects
        private void SearchReservations()
        {
            int campgroundIdNumber = CLIHelper.GetInteger("Please Select a Campground: ");


            newCampground.Campground_Id = campgroundIdNumber;
            DateTime StartDate     = new DateTime(2019, 5, 1);
            DateTime SeaWallClose  = new DateTime(2019, 9, 30);
            DateTime SchoodicClose = new DateTime(2019, 10, 31);
            DateTime UapcClose     = new DateTime(2019, 11, 30);



            if (campgroundId.Contains(newCampground.Campground_Id) == false)
            {
                Console.WriteLine();
                Console.WriteLine("Please select a valid campground.");
                Console.WriteLine();
                SearchReservations();
            }

            DateTime FromDate = CLIHelper.GetDateTime("What is the arrival date? YYYY-MM-DD");

            if (newCampground.Campground_Id == 2 || newCampground.Campground_Id == 3 || newCampground.Campground_Id == 7)
            {
                if (FromDate < StartDate && FromDate != StartDate)
                {
                    Console.WriteLine();
                    Console.WriteLine("The campground is closed.");
                    Console.WriteLine();
                    SearchReservations();
                }
            }

            DateTime ToDate = CLIHelper.GetDateTime("What is the depature date? YYYY-MM-DD");

            if (newCampground.Campground_Id == 2)
            {
                if (ToDate > SeaWallClose && ToDate != SeaWallClose)
                {
                    Console.WriteLine();
                    Console.WriteLine("The campground closes on September 30th.");
                    Console.WriteLine();
                    SearchReservations();
                }
            }
            if (newCampground.Campground_Id == 3)
            {
                if (ToDate > SchoodicClose && ToDate != SchoodicClose)
                {
                    Console.WriteLine();
                    Console.WriteLine("The campground closes on October 31st.");
                    Console.WriteLine();
                    SearchReservations();
                }
            }
            if (newCampground.Campground_Id == 7)
            {
                if (ToDate > SchoodicClose && ToDate != SchoodicClose)
                {
                    Console.WriteLine();
                    Console.WriteLine("The campground closes on November 30th.");
                    Console.WriteLine();
                    SearchReservations();
                }
            }



            Console.Clear();


            newCampground.Daily_Fee  = Convert.ToDecimal(campgroundDAO.GetDailyFee(newCampground.Campground_Id));
            newReservation.From_Date = FromDate;
            newReservation.To_Date   = ToDate;
            int numberOfDays = (ToDate - FromDate).Days;


            IList <Site> siteReservations = siteDAO.SearchReservations(newCampground.Campground_Id, FromDate, ToDate);



            if (siteReservations.Count > 0)
            {
                Console.WriteLine("Results Matching Your Search Criteria");
                Console.WriteLine();
                Console.WriteLine("SiteID".PadRight(11) + "Max Occupancy".PadRight(15) + "Is Accesible".PadRight(15) + "Max RV Length".PadRight(15) + "Utilities".PadRight(14) + "Total Cost".PadRight(15));
                foreach (Site detail in siteReservations)
                {
                    string accessible;

                    siteIdList.Add(detail.Site_Id);

                    if (detail.Accessible == true)
                    {
                        accessible = "Yes";
                        Console.WriteLine(detail.Site_Id.ToString().PadRight(11) + detail.Max_Occupancy.ToString().PadRight(15) + accessible.PadRight(15) + detail.Max_Rv_Length.ToString().PadRight(15) + Utilities[detail.Utilities].PadRight(15) + ("$" + (numberOfDays * newCampground.Daily_Fee).ToString("0.00").PadRight(20)));
                    }
                    else if (detail.Accessible == false)
                    {
                        accessible = "No";
                        Console.WriteLine(detail.Site_Id.ToString().PadRight(11) + detail.Max_Occupancy.ToString().PadRight(15) + accessible.PadRight(15) + detail.Max_Rv_Length.ToString().PadRight(15) + Utilities[detail.Utilities].PadRight(15) + "$" + (numberOfDays * newCampground.Daily_Fee).ToString("0.00").PadRight(20));
                    }
                }
                ReserveSiteMenu();
                Console.ReadLine();
            }
            else
            {
                Console.WriteLine("**** NO RESERVATIONS AVAILABLE ****");
            }
        }