/// <summary>
        /// The override of ExecuteSelection handles whatever selection was made by the user.
        /// This is where any business logic is executed.
        /// </summary>
        /// <param name="choice">"Key" of the user's menu selection</param>
        /// <returns></returns>
        protected override bool ExecuteSelection(string choice)
        {
            switch (choice)
            {
            case "1":     // Do whatever option 1 is

                int campgroundChoice = CLIMenu.GetInteger($"Which Campground?");
                if (campgroundChoice > 0 && campgroundChoice <= park.Campgrounds.Count)
                {
                    Campground campground = park.Campgrounds[campgroundChoice - 1];
                    campground.Sites = siteDao.GetSiteId(campground.CampgroundId);

                    string arrivalDate   = CLIMenu.GetString("What is your arrival date? (yyyy-mm-dd)");
                    string departureDate = CLIMenu.GetString("What is your departure date?(yyyy-mm-dd)");


                    SiteMenu siteMenu = new SiteMenu(park, campground, siteDao, reservationDao, arrivalDate, departureDate);
                    siteMenu.Run();
                }
                else
                {
                    Console.WriteLine("That campsite is not in our database.");
                }

                Pause("");
                return(true);

            case "2":     // Do whatever option 2 is
                WriteError("When this option is complete, we will exit this submenu by returning false from the ExecuteSelection method.");
                Pause("");
                return(false);
            }
            return(true);
        }
Пример #2
0
        public void CheckSiteId()
        {
            // Assign
            SiteSqlDAO dao = new SiteSqlDAO(connectionString);

            // Act
            IList <Site> list = dao.GetSiteId(blackWoods);

            // Assert
            Assert.AreEqual(blackWoods, list[0].CampgroundId);
        }
        public void CheckIfSiteIsReserved()
        {
            // Arrange
            SiteSqlDAO        siteDao = new SiteSqlDAO(connectionString);
            ReservationSqlDAO resDao  = new ReservationSqlDAO(connectionString);


            // Act
            IList <Site> sites = siteDao.GetSiteId(name);

            sites[0].Reservations  = resDao.getAllReservations(siteOne);
            sites[0].UserStartTime = DateTime.Today.AddDays(-2);
            sites[0].UserEndTime   = DateTime.Today.AddDays(3);


            // Assert
            Assert.AreEqual(true, sites[0].IsBooked);
        }