Пример #1
0
        private void ApplicationControl()
        {
            SkiRunRepository skiRunRepository = new SkiRunRepository();

            ConsoleView.DisplayWelcomeScreen();

            using (skiRunRepository)
            {
                List <SkiRun> skiRuns = skiRunRepository.GetSkiAllRuns();

                while (active)
                {
                    AppEnum.ManagerAction userActionChoice;

                    userActionChoice = ConsoleView.GetUserActionChoice();

                    switch (userActionChoice)
                    {
                    case AppEnum.ManagerAction.None:
                        break;

                    case AppEnum.ManagerAction.ListAllSkiRuns:
                        ConsoleView.DisplayAllSkiRuns(skiRuns);
                        ConsoleView.DisplayContinuePrompt();
                        break;

                    case AppEnum.ManagerAction.DisplaySkiRunDetail:
                        break;

                    case AppEnum.ManagerAction.DeleteSkiRun:
                        //
                        // TODO write a ConsoleView method to get the ski run ID
                        //
                        skiRunRepository.DeleteSkiRun(1);
                        ConsoleView.DisplayReset();
                        ConsoleView.DisplayMessage("Ski Run ID: 1 had been deleted.");
                        ConsoleView.DisplayContinuePrompt();
                        break;

                    case AppEnum.ManagerAction.AddSkiRun:
                        break;

                    case AppEnum.ManagerAction.UpdateSkiRun:
                        break;

                    case AppEnum.ManagerAction.QuerySkiRunsByVertical:
                        break;

                    case AppEnum.ManagerAction.Quit:
                        active = false;
                        break;

                    default:
                        break;
                    }
                }
            }

            ConsoleView.DisplayExitPrompt();
        }
Пример #2
0
        /// <summary>
        /// Updates a specific ski run's information in the data source with data entered by the user
        /// </summary>
        /// <param name="skiRunRepository"></param>
        /// <param name="skiRuns"></param>
        private static void UpdateSkiRun()
        {
            SkiRunBusiness skiRunBusiness = new SkiRunBusiness(skiRunRepository);
            SkiRun         aSkiRun        = new SkiRun();

            using (skiRunBusiness)
            {
                List <SkiRun> skiRuns = skiRunRepository.SelectAll();
                //Variable Declarations.


                ConsoleView.DisplayReset();

                //Display all ski runs.
                ConsoleView.DisplayAllSkiRuns(skiRuns, false);
                Console.WriteLine();
                Console.WriteLine();

                //Get the information for the ski run to be updated and display it on the screen.
                try
                {
                    //Display the ski run information on the screen.
                    //ConsoleView.DisplaySkiRunDetail(skiRunRepository.GetSkiRunByID(ConsoleView.GetIntegerFromUser("Enter the ID for the Ski Run: ")));
                    aSkiRun = skiRunRepository.SelectById(ConsoleView.GetIntegerFromUser("Enter the ID for the Ski Run: "));
                    ConsoleView.DisplaySkiRunDetail(aSkiRun);
                }
                catch (Exception ex)
                {
                    //Display the error message for the error that occurred.
                    CatchIOExceptions(ex);
                    return;
                }

                //Get the new Name and Vertical feet from the user.
                Console.WriteLine();
                Console.WriteLine();
                aSkiRun.Name     = ConsoleView.GetUserResponse("Enter the new name for the Ski Run: ");
                aSkiRun.Vertical = ConsoleView.GetIntegerFromUser("Enter the new vertical (in feet) for the Ski Run: ");

                //Update the ski run.
                try
                {
                    //Update the ski run information.
                    skiRunRepository.Update(aSkiRun);

                    //Display a message to the user that the record was updated.
                    ConsoleView.DisplayReset();
                    ConsoleView.DisplayMessage($"The information for the {aSkiRun.Name} ski run has been updated.");
                    ConsoleView.DisplayContinuePrompt();
                }
                catch (Exception ex)
                {
                    //Display the error message for the error that occurred.
                    CatchIOExceptions(ex);
                    return;
                }
            }
        }
Пример #3
0
        private static void ListAllSkiRuns()
        {
            SkiRunBusiness skiRunBusiness = new SkiRunBusiness(skiRunRepository);
            List <SkiRun>  skiRuns;

            using (skiRunBusiness)
            {
                skiRuns = skiRunBusiness.SelectAll();
            }
            ConsoleView.DisplayAllSkiRuns(skiRuns);
            ConsoleView.DisplayContinuePrompt();
        }
Пример #4
0
        private void ListAllSkiRuns()
        {
            SkiRunBusiness skiRunBusiness = new SkiRunBusiness(skiRunRepository);

            using (skiRunBusiness)
            {
                List <SkiRun> skiRuns = skiRunRepository.SelectAll();
                ConsoleView.DisplayAllSkiRuns(skiRuns, true);
            }

            ConsoleView.DisplayContinuePrompt();
        }
Пример #5
0
        private static void ListAllSkiRuns()
        {
            SkiRunRepositoryXML_DS skiRunRepository = new SkiRunRepositoryXML_DS();
            List <SkiRun>          skiRuns;


            using (skiRunRepository)
            {
                skiRuns = skiRunRepository.SelectAllRuns();
            }

            ConsoleView.DisplayAllSkiRuns(skiRuns);
            ConsoleView.DisplayContinuePrompt();
        }
Пример #6
0
        /// <summary>
        /// Deletes a record from the data source using the ID value entered by the user
        /// </summary>
        /// <param name="skiRunRepository"></param>
        /// <param name="skiRuns"></param>
        private static void DeleteSkiRun()
        {
            SkiRunBusiness skiRunBusiness = new SkiRunBusiness(skiRunRepository);
            List <SkiRun>  skiRuns        = skiRunRepository.SelectAll();
            //Variable declarations.
            int skiRunID = 0;

            //reset display
            ConsoleView.DisplayReset();
            using (skiRunBusiness)
            {
                //Display all ski runs.
                ConsoleView.DisplayAllSkiRuns(skiRuns, false);
                Console.WriteLine();
                Console.WriteLine();

                //Get the ID for the ski run from the user.
                skiRunID = ConsoleView.GetIntegerFromUser("Enter Ski Run ID to delete: ");

                try
                {
                    //Delete the ski run entered.
                    skiRunRepository.Delete(skiRunID);

                    //Display a message to the user that the ski run has been deleted.
                    ConsoleView.DisplayReset();
                    ConsoleView.DisplayMessage($"Ski Run ID: {skiRunID} had been deleted.");
                    ConsoleView.DisplayContinuePrompt();
                }
                catch (Exception ex)
                {
                    //Display the error message for the error that occurred.
                    CatchIOExceptions(ex);
                }
            }
        }
Пример #7
0
        private void ApplicationControl()
        {
            SkiRunRepositoryXML skiRunRepository = new SkiRunRepositoryXML();

            ConsoleView.DisplayWelcomeScreen();

            using (skiRunRepository)
            {
                List <SkiRun> skiRuns = skiRunRepository.GetSkiAllRuns();

                int    skiRunID;
                SkiRun skiRun;
                string message;

                while (active)
                {
                    AppEnum.ManagerAction userActionChoice;

                    userActionChoice = ConsoleView.GetUserActionChoice();

                    switch (userActionChoice)
                    {
                    case AppEnum.ManagerAction.None:
                        break;

                    case AppEnum.ManagerAction.ListAllSkiRuns:
                        ConsoleView.DisplayAllSkiRuns(skiRuns);

                        ConsoleView.DisplayContinuePrompt();
                        break;

                    case AppEnum.ManagerAction.DisplaySkiRunDetail:
                        skiRunID = ConsoleView.GetSkiRunID(skiRuns);
                        skiRun   = skiRunRepository.GetSkiRunByID(skiRunID);

                        ConsoleView.DisplaySkiRun(skiRun);
                        ConsoleView.DisplayContinuePrompt();
                        break;

                    case AppEnum.ManagerAction.AddSkiRun:
                        skiRun = ConsoleView.AddSkiRun();
                        skiRunRepository.InsertSkiRun(skiRun);

                        ConsoleView.DisplayContinuePrompt();
                        break;

                    case AppEnum.ManagerAction.UpdateSkiRun:
                        skiRunID = ConsoleView.GetSkiRunID(skiRuns);
                        skiRun   = skiRunRepository.GetSkiRunByID(skiRunID);

                        skiRun = ConsoleView.UpdateSkiRun(skiRun);

                        skiRunRepository.UpdateSkiRun(skiRun);
                        break;

                    case AppEnum.ManagerAction.DeleteSkiRun:
                        skiRunID = ConsoleView.GetSkiRunID(skiRuns);
                        skiRunRepository.DeleteSkiRun(skiRunID);

                        ConsoleView.DisplayReset();
                        message = String.Format("Ski Run ID: {0} had been deleted.", skiRunID);
                        ConsoleView.DisplayMessage(message);
                        ConsoleView.DisplayContinuePrompt();
                        break;

                    case AppEnum.ManagerAction.QuerySkiRunsByVertical:
                        List <SkiRun> matchingSkiRuns = new List <SkiRun>();

                        int minimumVertical;
                        int maximumVertical;
                        ConsoleView.GetVerticalQueryMinMaxValues(out minimumVertical, out maximumVertical);

                        matchingSkiRuns = skiRunRepository.QueryByVertical(minimumVertical, maximumVertical);

                        ConsoleView.DisplayQueryResults(matchingSkiRuns);
                        ConsoleView.DisplayContinuePrompt();
                        break;

                    case AppEnum.ManagerAction.Quit:
                        active = false;
                        break;

                    default:
                        break;
                    }
                }
            }

            ConsoleView.DisplayExitPrompt();
        }
Пример #8
0
        private void ApplicationControl()
        {
            SkiRunRepository skiRunRepository = new SkiRunRepository();

            ConsoleView.DisplayWelcomeScreen();

            using (skiRunRepository)
            {
                List <SkiRun> skiRuns = skiRunRepository.GetSkiAllRuns();

                while (active)
                {
                    AppEnum.ManagerAction userActionChoice;
                    int           vertical;
                    int           skiRunID;
                    SkiRun        skiRun;
                    string        skiRunString;
                    List <SkiRun> ski2 = new List <SkiRun>();

                    userActionChoice = ConsoleView.GetUserActionChoice();

                    switch (userActionChoice)
                    {
                    case AppEnum.ManagerAction.None:
                        break;

                    case AppEnum.ManagerAction.ListAllSkiRuns:
                        ConsoleView.DisplayAllSkiRuns(skiRuns);
                        ConsoleView.DisplayContinuePrompt();
                        break;

                    case AppEnum.ManagerAction.DisplaySkiRunDetail:
                        ConsoleView.DisplayAllSkiRuns(skiRuns);
                        ski2 = skiRunRepository.GetSkiRunByID(ConsoleView.DisplayGetSkiRunIDChoice(skiRuns));
                        ConsoleView.DisplaySkiRunDetails(ski2);
                        ConsoleView.DisplayContinuePrompt();

                        break;

                    case AppEnum.ManagerAction.DeleteSkiRun:
                        skiRunRepository.DeleteSkiRun(ConsoleView.DisplayGetSkiRunIDChoice(skiRuns));
                        ConsoleView.DisplayReset();
                        ConsoleView.DisplayMessage("Ski Run has been deleted.");
                        ConsoleView.DisplayContinuePrompt();
                        break;

                    case AppEnum.ManagerAction.AddSkiRun:

                        skiRun          = new SkiRun();
                        skiRun.ID       = ConsoleView.DisplayGetSkiRunID();
                        skiRun.Name     = ConsoleView.DisplayGetSkiRunName();
                        skiRun.Vertical = ConsoleView.DisplayGetSkiRunVertical();
                        skiRunRepository.InsertSkiRun(skiRun);
                        ConsoleView.DisplayAllSkiRuns(skiRuns);
                        ConsoleView.DisplayNewSkiRunMessage();

                        break;

                    case AppEnum.ManagerAction.UpdateSkiRun:

                        skiRun    = new SkiRun();
                        skiRun.ID = ConsoleView.DisplayGetSkiRunIDChoice(skiRuns);
                        skiRunRepository.UpdateSkiRun(skiRun);

                        Console.WriteLine();

                        break;

                    case AppEnum.ManagerAction.QuerySkiRunsByVertical:
                        int minimumVertical = skiRunRepository.GetMinimumVertical();
                        int maximumVertical = skiRunRepository.GetMaximumVertical();

                        //Sorts all the available entries and pushes out those that match into a new list.
                        List <SkiRun> matchingSkiRuns = skiRunRepository.QueryByVertical(minimumVertical, maximumVertical);
                        ConsoleView.DisplayReset();

                        //Displays the new list.
                        Console.WriteLine("Ski Runs with a vertical between " + minimumVertical + " and " + maximumVertical + ".");
                        skiRunRepository.DisplayQueriedVertical(matchingSkiRuns);
                        ConsoleView.DisplayContinuePrompt();
                        break;

                    case AppEnum.ManagerAction.Quit:
                        active = false;
                        break;

                    default:
                        break;
                    }
                }
            }

            ConsoleView.DisplayExitPrompt();
        }
Пример #9
0
        private void ApplicationControl()
        {
            SkiRunRepository skiRunRepository = new SkiRunRepository();

            ConsoleView.DisplayWelcomeScreen();

            using (skiRunRepository)
            {
                List <SkiRun> skiRuns = skiRunRepository.GetSkiAllRuns();

                while (active)
                {
                    AppEnum.ManagerAction userActionChoice;

                    int    skiRunID = 1;
                    SkiRun skiRun   = new SkiRun();
                    string message;

                    userActionChoice = ConsoleView.GetUserActionChoice();

                    switch (userActionChoice)
                    {
                    case AppEnum.ManagerAction.None:
                        break;

                    case AppEnum.ManagerAction.ListAllSkiRuns:
                        ConsoleView.DisplayAllSkiRuns(skiRuns);
                        ConsoleView.DisplayContinuePrompt();
                        break;

                    case AppEnum.ManagerAction.DisplaySkiRunDetail:
                        ConsoleView.GetSkiRunID(skiRuns);
                        skiRunRepository.GetSkiRunByID(skiRunID);
                        break;

                    case AppEnum.ManagerAction.DeleteSkiRun:
                        ConsoleView.GetSkiRunID(skiRuns);
                        skiRunRepository.DeleteSkiRun(skiRunID);
                        ConsoleView.DisplayReset();
                        ConsoleView.DisplayMessage($"Ski Run ID:" + skiRunID + "has been deleted.");
                        ConsoleView.DisplayContinuePrompt();
                        break;

                    case AppEnum.ManagerAction.AddSkiRun:
                        ConsoleView.DisplayReset();
                        ConsoleView.GetAddSkiRun(skiRun);
                        skiRunRepository.InsertSkiRun(skiRun);

                        break;

                    case AppEnum.ManagerAction.UpdateSkiRun:
                        break;

                    case AppEnum.ManagerAction.QuerySkiRunsByVertical:

                        break;

                    case AppEnum.ManagerAction.Quit:
                        active = false;
                        break;

                    default:
                        break;
                    }
                }
            }

            ConsoleView.DisplayExitPrompt();
        }