Beispiel #1
0
        public void GetAllCampgroundsInParkTest()
        {
            //Arrange
            CampgroundSqlDAL campgroundSqlDAL = new CampgroundSqlDAL();

            //Act
            Dictionary <int, Campground> campgrounds = campgroundSqlDAL.GetAllCampgroundsInPark("Arches");

            //Assert
            Assert.AreEqual(4, campgrounds.Count);
            Assert.AreEqual(5, campgrounds[4].Open_From_MM);
        }
        private Dictionary <int, Campground> GetAndPrintCampgrounds(string parkName)
        {
            CampgroundSqlDAL             campgroundDAL = new CampgroundSqlDAL();
            Dictionary <int, Campground> campgrounds   = campgroundDAL.GetAllCampgroundsInPark(parkName);

            //int campgroundNameLength

            Console.WriteLine();
            Console.WriteLine("{0, -6}{1,-35}{2,-12}{3,-12}{4,-14}", "", "Name", "Open", "Close", "Daily Fee");
            Console.WriteLine(String.Format("").PadRight(80, '='));

            foreach (KeyValuePair <int, Campground> campground in campgrounds)
            {
                Console.WriteLine('#' + campground.Key.ToString().PadRight(5) + campground.Value.Name.PadRight(35) + Months[campground.Value.Open_From_MM].PadRight(12) +
                                  Months[campground.Value.Open_To_MM].PadRight(12) + String.Format("{0:c}", campground.Value.Daily_Fee).PadRight(14));
            }
            return(campgrounds);
        }
        private void GetParkWideAvailability(string parkName)
        {
            CampgroundSqlDAL             campgroundDAL = new CampgroundSqlDAL();
            Dictionary <int, Campground> campgrounds   = campgroundDAL.GetAllCampgroundsInPark(parkName);

            Console.Clear();
            DateTime startDate = CLIHelper.GetDateTime("What is the arrival date (YYYY/MM/DD)?:");
            DateTime endDate   = CLIHelper.GetDateTime("What is the departure date (YYYY/MM/DD)?:");

            List <Site> availableSites = campgroundDAL.GetParkAvailability(parkName, startDate, endDate);

            if (availableSites.Count > 0)
            {
                Console.Clear();
                Console.WriteLine("Results Matching Your Search Criteria");
                Console.WriteLine("{0,13}{1,12}{2,13}{3,14}{4,9}{5,10}{6,7}", "Campground", "Site No.", "Max Occup.", "Accessible?", "RV Len", "Utility", "Cost");
                List <int> availableSiteNumbers = new List <int>();

                int totalReservDays = (int)(endDate - startDate).TotalDays;

                foreach (var site in availableSites)
                {
                    Campground campground = campgrounds.Where(i => i.Value.CampgroundId == site.CampgroundID).First().Value;
                    availableSiteNumbers.Add(site.SiteNumber);
                    double cost = totalReservDays * campground.Daily_Fee;

                    Console.WriteLine(campground.Name.PadRight(13) + site.SiteNumber.ToString().PadRight(12) + site.MaxOccupancy.ToString().PadRight(13) +
                                      site.WheelchairAccess.PadRight(19) + site.MaxRVLength.PadRight(9) + site.UtilityHookups.PadRight(10) + cost);
                }

                BookReservation(availableSiteNumbers, startDate, endDate);
            }
            else
            {
                Console.WriteLine("Sorry, there are no sites available in the specified date range.");
                bool stillBooking = CLIHelper.GetBoolFromYesOrNo("Would you like to enter another date range?");
            }
        }