Beispiel #1
0
        /// <summary>
        /// Entry point for the park reservation cli
        /// </summary>
        /// <param name="args">Command line arguments which are currently ignored</param>
        static void Main(string[] args)
        {
            CLIHelper.EnableDebugInfo = true;

            try
            {
                var builder = new ConfigurationBuilder()
                              .SetBasePath(Directory.GetCurrentDirectory())
                              .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
                IConfigurationRoot configuration = builder.Build();

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

                IParkDAO         parkDb         = new ParkDAO(connectionString);
                IUserSecurityDAO userSecurityDb = new UserSecurityDAO(connectionString);
                UserManager      userMgr        = new UserManager(userSecurityDb);

                ParkReservationCLI cli = new ParkReservationCLI(userMgr, parkDb);
                cli.StartMenu();
            }
            catch (Exception e)
            {
                CLIHelper.DisplayDebugInfo(e);
            }
        }
        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("Project");

            IParkDAO           db       = new ParkDAO(connectionString);
            IUserSecurityDAO   security = new UserSecurityDAO(connectionString);
            UserManager        userMgr  = new UserManager(security);
            ParkReservationCLI cli      = new ParkReservationCLI(userMgr, db);

            cli.Run();
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            ParkReservationCLI cli = new ParkReservationCLI();

            cli.RunCLI();
        }
        static void Main(string[] args)
        {
            // Sample Code to get a connection string from the
            // App.Config file
            // Use this so that you don't need to copy your connection string all over your code!
            while (true)
            {
                ParkReservationCLI parkReservationCLI = new ParkReservationCLI();

                //Goes to main menu where the user can select a park then outputs that selected park
                Park _userChoicePark = parkReservationCLI.GoToMainMenu();
                List <Campground> _userCampground = parkReservationDAL.GetCampgroundsInPark(_userChoicePark);

                bool loop = true;
                while (loop)
                {
                    parkReservationCLI.DisplayParkInfo(_userChoicePark);

                    int parkInfoSelection = CLIHelper.GetInteger(3);


                    switch (parkInfoSelection)
                    {
                    case 1:
                        Console.Clear();
                        //This calls the GetCampgroundsInPark method with the user selected park as the parameter
                        //Which returns a list for the DisplayParkCampgrounds method which prints that list to the screen
                        parkReservationCLI.DisplayParkCampgrounds(parkReservationDAL.GetCampgroundsInPark(_userChoicePark));
                        parkReservationCLI.DisplayParkCampgroundsCommand(parkReservationDAL.GetCampgroundsInPark(_userChoicePark));
                        int  selection = CLIHelper.GetInteger(2);
                        bool menuLoop  = true;
                        switch (selection)
                        {
                        case 1:
                            while (menuLoop)
                            {
                                Console.Clear();
                                parkReservationCLI.DisplayParkCampgrounds(_userCampground);
                                menuLoop = parkReservationCLI.DisplayReservationMenu();
                            }
                            break;

                        case 2:
                            break;
                        }
                        break;

                    case 2:
                        parkReservationCLI.DisplayParkCampgrounds(parkReservationDAL.GetCampgroundsInPark(_userChoicePark));

                        Console.ReadKey();
                        break;

                    case 3:
                        //This breaks off this method and returns to the main menu
                        loop = false;
                        break;
                    }
                }
            }
        }