Exemplo n.º 1
0
        static void Main(string[] args)
        {
            // Get the connection string from the appsettings.json file
            IConfigurationBuilder builder = new ConfigurationBuilder()
                                            .SetBasePath(Directory.GetCurrentDirectory())
                                            .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

            IConfigurationRoot configuration = builder.Build();

            string connectionString = configuration.GetConnectionString("npcampground");

            IParksDAO       parksDAO       = new ParksSqlDAO(connectionString);
            ICampgroundDAO  campgroundDAO  = new CampgroundSqlDAO(connectionString);
            ISiteDAO        siteDAO        = new SiteSqlDAO(connectionString);
            IReservationDAO reservationDAO = new ReservationSqlDAO(connectionString);

            MainCLI       mainCLI       = new MainCLI(parksDAO, campgroundDAO, siteDAO, reservationDAO);
            ParkCLI       parkCLI       = new ParkCLI(parksDAO, campgroundDAO, siteDAO, reservationDAO);
            CampGroundCLI campGroundCLI = new CampGroundCLI(parksDAO, campgroundDAO, siteDAO, reservationDAO);
            SiteCLI       siteCLI       = new SiteCLI(parksDAO, campgroundDAO, siteDAO, reservationDAO);

            mainCLI.RunMainMenuCLI();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Runs menu to give user a choice of parks.
        /// </summary>
        public void RunParkCLI()
        {
            Console.Clear();
            PrintHeader();
            GetAllParks();
            PrintParkChoices();

            while (true)
            {
                string       userChoice = Console.ReadLine();
                IList <Park> parks      = parksDAO.GetAllParks();
                foreach (Park park in parks)
                {
                    string parkIdString = park.ParkId.ToString();
                    if (userChoice == parkIdString)
                    {
                        CampGroundCLI campGroundCLI = new CampGroundCLI(parksDAO, campgroundDAO, siteDAO, reservationDAO);
                        campGroundCLI.RunCampGroundCLI(park.Name, park.ParkId);
                    }
                    else
                    {
                        switch (userChoice.ToLower())
                        {
                        case "p":
                            Console.Clear();
                            RunMainMenuCLI();
                            break;

                        default:
                            Console.WriteLine("The command provided was not a valid command, please try again.", Color.OrangeRed);
                            break;
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Runs menu to give user a choice of sites from the choosen campground.
        /// </summary>
        /// <param name="parkName"></param>
        /// <param name="parkId"></param>
        /// <param name="campgroundId"></param>
        /// <param name="campgroundName"></param>
        /// <param name="dailyFee"></param>
        /// <param name="fromDate"></param>
        /// <param name="toDate"></param>
        public void RunSiteCLI(string parkName, int parkId, int campgroundId, string campgroundName, decimal dailyFee, DateTime fromDate, DateTime toDate)
        {
            userParkName       = parkName;
            userParkId         = parkId;
            userCampgroundID   = campgroundId;
            userCampgroundName = campgroundName;
            userDailyFee       = dailyFee;
            userFromDate       = fromDate;
            userToDate         = toDate;

            Console.Clear();
            PrintHeader();
            GetSiteList();

            while (true)
            {
                string       userChoice = Console.ReadLine();
                IList <Site> sites      = siteDAO.Search(userCampgroundID, userFromDate, userToDate);
                foreach (Site site in sites)
                {
                    siteIdString = site.SiteId.ToString();
                    if (userChoice == siteIdString)
                    {
                        int     totalDays = HowManyDays(userFromDate, userToDate);
                        decimal totalCost = totalDays * userDailyFee;

                        string apptConfirm = CLIHelper.GetString($"Your total is {totalCost:C}, would you like to confirm your reservation. (Y)es or (N): ");
                        bool   confirmAppointment;
                        if (apptConfirm == "y")
                        {
                            confirmAppointment = true;
                        }
                        else
                        {
                            confirmAppointment = false;
                        }
                        if (confirmAppointment == true)
                        {
                            reservationName = CLIHelper.GetString("What name would you like to make your reservation under?: ");
                            reservationDAO.MakeReservation(userFromDate, userToDate, reservationName, site.SiteId);
                            PrintConfirmationPage();
                        }
                        else
                        {
                            // Temporary for tonight
                            Console.WriteLine("Fine Then!");
                            Console.ReadLine();
                        }
                    }
                }
                switch (userChoice.ToLower())
                {
                case "p":
                    Console.Clear();
                    CampGroundCLI campgroundCLI = new CampGroundCLI(parksDAO, campgroundDAO, siteDAO, reservationDAO);
                    campgroundCLI.RunCampGroundCLI(parkName, parkId);
                    break;

                default:
                    Console.WriteLine("The command provided was not a valid command, please try again.");
                    break;
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Retrieves all sites from the db and displays Top 5 on the screen.
        /// </summary>
        private void GetSiteList()
        {
            int totalDays = HowManyDays(userFromDate, userToDate);

            totalCost = totalDays * userDailyFee;
            IList <Site> sites = siteDAO.Search(userCampgroundID, userFromDate, userToDate);
            {
                Console.WriteLine();
                Console.WriteLine($"                                             {userCampgroundName}                     |Total Price for {totalDays} Days| {totalCost:C}                       ", Color.Yellow);
                Console.WriteLine("___________________________________________________________________________________________________________________________________________________________________________", Color.DimGray);
                string      menu   = "  [ {0} ]           [ {1} ]         [ {2} ]     [ {3} ]          [ {4} ]   [ {5} ]                                                       ";
                Formatter[] fruits = new Formatter[]
                {
                    new Formatter("Site ID", Color.WhiteSmoke),
                    new Formatter("Maximum Occupancy", Color.WhiteSmoke),
                    new Formatter("OHandicap Accessible", Color.WhiteSmoke),
                    new Formatter("Maximum RV Length", Color.WhiteSmoke),
                    new Formatter("Utilities Available", Color.WhiteSmoke),
                    new Formatter("Campsite Number", Color.WhiteSmoke),
                };
                Console.WriteFormatted(menu, Color.Yellow, fruits);
                Console.WriteLine();
                Console.WriteLine("___________________________________________________________________________________________________________________________________________________________________________", Color.DimGray);

                if (sites.Count == 0)
                {
                    Console.WriteLine("---------------------------------------------------        Sorry, no sites are available for the provided dates        ---------------------------------------------------", Color.OrangeRed);
                    PrintNoSitesAvailableChoices();
                    while (true)
                    {
                        string userChoice = Console.ReadLine();

                        switch (userChoice.ToLower())
                        {
                        case "p":

                            CampGroundCLI campGroundCLI = new CampGroundCLI(parksDAO, campgroundDAO, siteDAO, reservationDAO);
                            campGroundCLI.RunCampGroundCLI(userParkName, userParkId);
                            break;

                        case "m":
                            RunMainMenuCLI();
                            return;

                        default:
                            Console.WriteLine("The command provided was not a valid command, please try again.", Color.OrangeRed);
                            break;
                        }
                    }
                }
                else
                {
                    foreach (Site site in sites)
                    {
                        string isAccessible = (site.Accesible == true) ? isAccessible = "Yes" : isAccessible = "No";
                        string hasUtilities = (site.Utilities == true) ? isAccessible = "Yes" : isAccessible = "No";
                        Console.WriteLine($"     {site.SiteId.ToString().PadRight(25)} {site.MaxOccupants.ToString().PadRight(30)}   {isAccessible.PadRight(15)}            {site.MaxRvLength + "ft.".PadRight(30)}    {hasUtilities.PadRight(20)}   {site.SiteNumber}              ", Color.Yellow);
                    }
                    Console.WriteLine("__________________________________________________________________________________________________________________________________________________________________________", Color.DimGray);
                    PrintSiteChoices();
                }
            }
        }