示例#1
0
        public void PrintParkCampGround(int parkSelection)
        {
            Console.Clear();
            CampGroundSqlDAL  campGroundsinPark = new CampGroundSqlDAL(databaseconnectionString);
            ParkSqlDAL        park             = new ParkSqlDAL(databaseconnectionString);
            List <Campground> printCampGrounds = new List <Campground>();

            try
            {
                printCampGrounds = campGroundsinPark.GetParkCampGround(park.GetParkID(parkSelection));
            }
            catch (SqlException ex)
            {
                Console.WriteLine("Invalid input. Please try again.");
                return;
            }
            Console.WriteLine("\tName".PadRight(35) + "Open".PadRight(13) + "Close".PadRight(13) + "Daily Fee");
            int count = 0;

            foreach (Campground campground in printCampGrounds)
            {
                Console.WriteLine($"#{count + 1} \t{printCampGrounds[count].ToString()}");
                count++;
            }
            CampGroundView(parkSelection);
        }
        public void GetParkCampGroundTest()
        {
            CampGroundSqlDAL  camptest = new CampGroundSqlDAL(dbconnectionString);
            List <Campground> camp     = camptest.GetParkCampGround(1);

            Assert.IsNotNull(camp);
            Assert.AreEqual(campground_count, camp.Count);
        }
示例#3
0
        public Dictionary <int, CampGround> ParkCampgrounds(int parkSelection)
        {
            CampGroundSqlDAL             campGroundSql = new CampGroundSqlDAL();
            Dictionary <int, CampGround> campgrounds   = new Dictionary <int, CampGround>();

            campgrounds = campGroundSql.ListCampground(parkSelection);

            return(campgrounds);
        }
示例#4
0
        public void GetCampgroundsTest()
        {
            List <CampGround> result = new List <CampGround>();

            CampGroundSqlDAL campgrounds = new CampGroundSqlDAL(connectionString);

            result = campgrounds.GetCampGrounds(1);

            Assert.AreEqual(3, result.Count);
        }
示例#5
0
        public void SearchAvailableSitesInPark(string arrival, string departure, int parkSelection)
        {
            Console.Clear();
            SiteSqlDAL  reservationAvailibility = new SiteSqlDAL(databaseconnectionString);
            List <Site> availableSites          = new List <Site>();

            try
            {
                availableSites = reservationAvailibility.ReservationAvailable(arrival, departure, parkSelection);
            }
            catch (SqlException ex)
            {
                Console.WriteLine();
                Console.WriteLine("Invalid input.  Please try again.");
                Console.WriteLine();
                return;
            }
            CampGroundSqlDAL  campGroundsinPark = new CampGroundSqlDAL(databaseconnectionString);
            ParkSqlDAL        park             = new ParkSqlDAL(databaseconnectionString);
            List <Campground> printCampGrounds = new List <Campground>();

            try
            {
                printCampGrounds = campGroundsinPark.GetParkCampGround(park.GetParkID(parkSelection));
            }
            catch (SqlException ex)
            {
                Console.WriteLine();
                Console.WriteLine("Invalid input.  Please try again.");
                Console.WriteLine();
                return;
            }
            Console.WriteLine();
            Console.WriteLine("Results Matching Your Search Criteria");
            Console.WriteLine("CampGround".PadRight(32) + "Site No.".PadRight(15) + "Max Occup.".PadRight(15) + "Accessible?".PadRight(15) + "Max RV Length".PadRight(15) + "Utility".PadRight(15) + "Cost".PadRight(15));

            int camp_id = 0;

            foreach (Site s in availableSites)
            {
                string campName = string.Empty;
                foreach (Campground camp in printCampGrounds)
                {
                    if (camp.Campground_id == s.Campground_id)
                    {
                        campName = camp.Name;
                        camp_id  = camp.Campground_id;
                    }
                }
                Console.WriteLine((campName + " ID:" + (camp_id).ToString()).PadRight(32) + s.ToString() + reservationAvailibility.PrintCost(s, arrival, departure));
            }
            ReservationConfirmationForPark(arrival, departure, camp_id, parkSelection);
            Console.ReadLine();
        }
        public void PrintCampGrounds(int parkId)
        {
            CampGroundSqlDAL  dal         = new CampGroundSqlDAL(DatabaseConnection);
            List <Campground> campgrounds = dal.GetCampGroundsInPark(parkId);

            _campgroundDictionary.Clear();
            for (int i = 1; i <= campgrounds.Count; i++)
            {
                Campground campground = campgrounds[i - 1];
                Console.WriteLine($"({campgrounds[i - 1].Id}){campgrounds[i - 1].Name,-20}  {campgrounds[i - 1].OpenFromMonthstr,-15} {campgrounds[i - 1].OpenToMonthstr,-20} {campgrounds[i - 1].DailyFee.ToString("c"),-20}");
                _campgroundDictionary.Add(i, campground);
            }
        }
示例#7
0
        public void GetParkInfo(Park park)
        {
            const string command_ViewCampgrounds   = "1";
            const string command_SearchReservation = "2";
            const string command_ReturnToPrevious  = "3";

            CampGroundSqlDAL  campground     = new CampGroundSqlDAL(connectionString);
            List <CampGround> allCampgrounds = campground.GetCampGrounds(park.ParkId);

            Console.Clear();
            Console.WriteLine("{0, -10}", park.Name);
            Console.WriteLine("Location: {0, -10}", park.Location);
            Console.WriteLine("Established: " + park.EstablishDate.ToString("MM/dd/yyyy"));
            Console.WriteLine("Area: {0:n0} sq km", park.Area);
            Console.WriteLine("Annual Visitors: {0:n0}", park.Visitors);
            Console.WriteLine();
            Console.WriteLine(park.Description);
            Console.WriteLine();
            Console.WriteLine("Select a Command");
            Console.WriteLine("1) View Campgrounds");
            Console.WriteLine("2) Search for Reservation");
            Console.WriteLine("3) Return to Previous Screen");


            Console.WriteLine();
            string command = Console.ReadLine();

            switch (command.ToLower())
            {
            case command_ViewCampgrounds:
                ViewCampGrounds(park.ParkId);
                break;

            case command_SearchReservation:
                SearchReservation(park.ParkId, command);
                break;

            case command_ReturnToPrevious:
                ViewParks();
                break;

            default:
                Console.WriteLine("The command provided was not a valid command, please try again.");

                break;
            }
        }
示例#8
0
        public void ViewCampGrounds(int parkId)
        {
            const string command_SearchReservation = "1";
            const string command_ReturnToPrevious  = "2";

            CampGroundSqlDAL  campground     = new CampGroundSqlDAL(connectionString);
            List <CampGround> allCampgrounds = campground.GetCampGrounds(parkId);

            Console.Clear();
            Console.WriteLine("{0,-11}{1,-25}{2,-10}{3,-10}{4, -10}", " ", "Name", "Open", "Close", "Daily Fee");
            foreach (CampGround item in allCampgrounds)
            {
                Console.WriteLine("#{0,-10}{1,-25}{2,-10}{3,-10}${4,-10:0.00}", item.CampgroundId, item.Name, item.OpenFrom, item.OpenTo, item.DailyFee);
                Console.WriteLine();
            }
            Console.WriteLine("Select a Command");
            Console.WriteLine("1) Search for Available Reservations");
            Console.WriteLine("2) Return to Parks");
            Console.WriteLine();
            string command = Console.ReadLine();

            Console.WriteLine();

            switch (command.ToLower())
            {
            case command_SearchReservation:
                SearchReservation(parkId, command);

                break;

            case command_ReturnToPrevious:
                ViewParks();
                break;

            default:
                Console.WriteLine("The command provided was not a valid command, please try again.");

                break;
            }
        }
示例#9
0
        ///Reservation SubMENU 2
        public void DateRangeSubMenu(int parkID)
        {
            Console.Clear();
            Console.WriteLine("{0, -5}{1, -36}{2, -20}{3, -20}{4, -20}", "ID", "Name", "Open", "Close", "Daily Fee");
            PrintCampGrounds(parkID);
            CampGroundSqlDAL dal = new CampGroundSqlDAL(DatabaseConnection);

            Console.WriteLine();

            Console.WriteLine($"Which Campground? Select valid ID or choose from the menu options below:");
            Console.WriteLine();
            Console.WriteLine("m) return to main menu");
            Console.WriteLine("p) return to previous screen");
            string campgroundSelection = Console.ReadLine();

            //Console.WriteLine("");
            Console.WriteLine();


            if (campgroundSelection == "m")
            {
                RunCLI();
            }
            if (campgroundSelection == "p")
            {
                SubSubMenu(parkID);
            }
            int selection = int.Parse(campgroundSelection);

            if (selection == 0)
            {
                RunCLI();
            }

            if (_campgroundDictionary.ContainsKey(selection))
            {
                ReservationSubMenu(selection);
            }
        }
        public void CampGroundMenu(int parkId)
        {
            Console.WriteLine("Select a CampGround Option: ");
            Console.WriteLine("1) View Campgrounds ");
            Console.WriteLine("2) Search for reservation ");
            Console.WriteLine("3) Return to Previous Screen ");
            string input = Console.ReadLine();

            Console.Clear();

            IParkDAL       parkDal = new ParkSqlDAL(DatabaseConnection);
            ICampGroundDAL cgDal   = new CampGroundSqlDAL(DatabaseConnection);

            Park park = parkDal.GetParkById(parkId);
            IList <CampGround> campGrounds = cgDal.GetCampGroundByPark(parkId);

            if (input == "1")
            {
                if (campGrounds.Count > 0)
                {
                    Console.WriteLine(park.Name + " " + "National Park Campgrounds");
                    Console.WriteLine();
                    Console.WriteLine("Campgound Id".PadRight(21) + "Name".PadRight(40) + "Open".PadRight(20) + "Close".PadRight(20) + "Daily Fee");

                    foreach (CampGround campGround in campGrounds)
                    {
                        Console.WriteLine("#" + campGround.CampGroundId.ToString().PadRight(20) + campGround.Name.ToString().PadRight(40) + GetMonthString(campGround.OpenFrom).ToString().PadRight(20) + GetMonthString(campGround.OpenTo).ToString().PadRight(20) + "$" + campGround.DailyFee.ToString("0.00"));
                    }

                    Console.WriteLine();
                    ReservationMenu(parkId);
                }
            }
            else if (input == "2")
            {
                if (campGrounds.Count > 0)
                {
                    Console.WriteLine(park.Name + " " + "National Park Campgrounds");
                    Console.WriteLine();
                    Console.WriteLine("  Campgound Id".PadRight(24) + "Name".PadRight(40) + "Open".PadRight(20) + "Close".PadRight(20) + "Daily Fee");
                    int choice = 1;
                    foreach (CampGround campGround in campGrounds)
                    {
                        Console.WriteLine(choice + ")" + " " + "#" + campGround.CampGroundId.ToString().PadRight(20) + campGround.Name.ToString().PadRight(40) + GetMonthString(campGround.OpenFrom).ToString().PadRight(20) + GetMonthString(campGround.OpenTo).ToString().PadRight(20) + "$" + campGround.DailyFee.ToString("0.00"));
                        choice++;
                    }

                    Console.WriteLine();
                    ReservationMenu(parkId);
                }
            }
            else if (input == "3")
            {
                Console.Clear();
                PrintMenu();
            }
            else
            {
                Console.WriteLine("Invalid Entry, please try again.");
            }
        }
        public void ReservationMenu(int parkId)
        {
            Console.WriteLine("Select an Option: ");
            Console.WriteLine("1) Search for Available Reservation ");
            Console.WriteLine("2) Return to Previous Screen ");
            string input = Console.ReadLine();


            if (input == "1")
            {
                //CampGroundMenu(parkId);

                // Prompt&Get for campgroundID: campgroundId
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("Which campground (enter 0 to cancel)? ");
                string inputCG = Console.ReadLine();
                if (inputCG == "0")
                {
                    Console.WriteLine();
                    ReservationMenu(parkId);
                }
                // Prompt&Get for arrive date: fromDate
                Console.WriteLine("What is the arrival date (mm/dd/yyyy)? ");
                string inputFD = Console.ReadLine();
                // Prompt&Get for depart date: toDate
                Console.WriteLine("What is the departure date (mm/dd/yyyy)? ");
                string inputTD = Console.ReadLine();

                int      campGroundId = int.Parse(inputCG);
                DateTime fromDate     = DateTime.Parse(inputFD);
                DateTime toDate       = DateTime.Parse(inputTD);


                ISiteDAL           siteDal     = new SiteSqlDAL(DatabaseConnection);
                IList <Site>       sites       = siteDal.GetAvailableSite(campGroundId, fromDate, toDate);
                ICampGroundDAL     cgDal       = new CampGroundSqlDAL(DatabaseConnection);
                IList <CampGround> campGrounds = cgDal.GetCampGroundByPark(parkId);


                double totalDays = (toDate - fromDate).TotalDays;
                if (sites.Count <= 0)
                {
                    Console.WriteLine("No available campsites, please enter an alternate DateRange. ");
                }
                else if (sites.Count > 0 && sites.Count < 8)
                {
                    Console.Clear();
                    Console.WriteLine("Results Matching Your Search Criteria");
                    Console.WriteLine();
                    Console.WriteLine();
                    Console.WriteLine("  Site No.".PadRight(20) + "Max Occup.".PadRight(20) + "Accessible?".PadRight(20) + "RV Len".PadRight(10) + "Utility".PadRight(10) + "Cost");


                    int choice = 1;
                    foreach (Site site in sites)
                    {
                        // Added ToString() to limit cost value to two decimal places
                        Console.WriteLine(choice + ")" + " " + site.SiteNumber.ToString().PadRight(20) + site.MaxOccupancy.ToString().PadRight(20) + site.IsAccessible.ToString().PadRight(20) + site.MaxRvLength.ToString().PadRight(10) + site.Utilities.ToString().PadRight(10) + "$" + (campGrounds[campGroundId - 1].DailyFee * (decimal)totalDays).ToString("0.00"));
                        choice++;
                    }
                    Console.WriteLine();
                    Console.WriteLine();
                    Console.WriteLine("Which site should be reserved (enter 0 to cancel)?");
                    string inputSite = Console.ReadLine();
                    Console.WriteLine("What name should the reservation be made under?");
                    string inputName = Console.ReadLine();

                    Reservation reservation = new Reservation()
                    {
                        Name     = inputName,
                        SiteId   = int.Parse(inputSite),
                        FromDate = fromDate,
                        ToDate   = toDate,
                        BookDate = DateTime.Now
                    };

                    IReservationDAL     resDal       = new ReservationSqlDAL(DatabaseConnection);
                    IList <Reservation> reservations = resDal.BookReservation(reservation);

                    Console.WriteLine();
                    Console.WriteLine($"The reservation has been made and the Confirmation ID is {reservation.ReservationId}");
                }
            }
            else if (input == "2")
            {
                Console.Clear();
                IParkDAL       parkDal = new ParkSqlDAL(DatabaseConnection);
                ICampGroundDAL cgDal   = new CampGroundSqlDAL(DatabaseConnection);

                Park park = parkDal.GetParkById(parkId);
                IList <CampGround> campGrounds = cgDal.GetCampGroundByPark(parkId);
                if (campGrounds.Count > 0)
                {
                    Console.WriteLine(park.Name + " " + "National Park Campgrounds");
                    Console.WriteLine();
                    Console.WriteLine("Campgound Id".PadRight(21) + "Name".PadRight(40) + "Open".PadRight(20) + "Close".PadRight(20) + "Daily Fee");

                    foreach (CampGround campGround in campGrounds)
                    {
                        Console.WriteLine("#" + campGround.CampGroundId.ToString().PadRight(20) + campGround.Name.ToString().PadRight(40) + GetMonthString(campGround.OpenFrom).ToString().PadRight(20) + GetMonthString(campGround.OpenTo).ToString().PadRight(20) + "$" + campGround.DailyFee.ToString("0.00"));
                    }
                }

                Console.WriteLine();
                CampGroundMenu(parkId);
            }
        }