Ejemplo n.º 1
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;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Displays a list of all ski runs
        /// </summary>
        /// <param name="skiRunRepository"></param>
        private static void DisplaySkiRunDetail()
        {
            SkiRunBusiness skiRunBusiness = new SkiRunBusiness(skiRunRepository);

            ConsoleView.DisplayReset();
            //ConsoleView.DisplayHeader("Display Ski Run Information");
            using (skiRunBusiness)
            {
                try
                {
                    //Display the ski run information on the screen.
                    ConsoleView.DisplaySkiRunDetail(skiRunRepository.SelectById(ConsoleView.GetIntegerFromUser("Enter the ID for the Ski Run: ")));
                    ConsoleView.DisplayContinuePrompt();
                }
                catch (Exception ex)
                {
                    ConsoleView.DisplayErrorMessage(ex.Message);
                    ConsoleView.DisplayContinuePrompt();
                }
            }
        }