Example #1
0
        /// <summary>
        /// Adds a record to the data source with information provided by the user
        /// </summary>
        /// <param name="skiRunRepository"></param>
        private static void AddSkiRun()
        {
            SkiRunBusiness skiRunBusiness = new SkiRunBusiness(skiRunRepository);
            //Variable Declarations.
            SkiRun aSkiRun = new SkiRun();

            ConsoleView.DisplayReset();

            //Get the ID, Name, and Vertical feet from the user.
            aSkiRun.ID       = ConsoleView.GetIntegerFromUser("Enter the ID for the Ski Run: ");
            aSkiRun.Name     = ConsoleView.GetUserResponse("Enter the name for the Ski Run: ");
            aSkiRun.Vertical = ConsoleView.GetIntegerFromUser("Enter the vertical (in feet) for the Ski Run: ");
            using (skiRunBusiness)
            {
                //Insert the new ski run.
                try
                {
                    //Insert the new record.
                    skiRunRepository.Insert(aSkiRun);

                    //Display a message to the user that the record was inserted.
                    ConsoleView.DisplayReset();
                    ConsoleView.DisplayMessage($"The information for the {aSkiRun.Name} ski run has been saved.");
                    ConsoleView.DisplayContinuePrompt();
                }
                catch (Exception ex)
                {
                    //Display the error message for the error that occurred.
                    CatchIOExceptions(ex);
                }
            }
        }
Example #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;
                }
            }
        }
Example #3
0
        private static void ListAllSkiRuns()
        {
            SkiRunBusiness skiRunBusiness = new SkiRunBusiness(skiRunRepository);
            List <SkiRun>  skiRuns;

            using (skiRunBusiness)
            {
                skiRuns = skiRunBusiness.SelectAll();
            }
            ConsoleView.DisplayAllSkiRuns(skiRuns);
            ConsoleView.DisplayContinuePrompt();
        }
Example #4
0
        private void ListAllSkiRuns()
        {
            SkiRunBusiness skiRunBusiness = new SkiRunBusiness(skiRunRepository);

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

            ConsoleView.DisplayContinuePrompt();
        }
Example #5
0
        /// <summary>
        /// Allows the user to select a list of ski runs based on the vertical value
        /// </summary>
        /// <param name="skiRunRepository"></param>
        private static void QuerySkiRunsByVertical()
        {
            SkiRunBusiness skiRunBusiness = new SkiRunBusiness(skiRunRepository);

            int[] minMaxValues = ConsoleView.DisplayGetSkiRunQuery();
            using (skiRunBusiness)
            {
                List <SkiRun> results = skiRunBusiness.QueryByVertical(minMaxValues[0], minMaxValues[1]);
                ConsoleView.DisplayQueryResults(results);
            }

            ConsoleView.DisplayContinuePrompt();
        }
Example #6
0
        private static void AddSkiRun()
        {
            SkiRunBusiness skiRunBusiness = new SkiRunBusiness(skiRunRepository);

            SkiRun skiRun;

            skiRun = ConsoleView.AddSkiRun();
            using (skiRunBusiness)
            {
                skiRunBusiness.Insert(skiRun);
            }

            ConsoleView.DisplayContinuePrompt();
        }
Example #7
0
        private static void UpdateSkiRun()
        {
            SkiRunBusiness skiRunBusiness = new SkiRunBusiness(skiRunRepository);

            List <SkiRun> skiRuns;
            SkiRun        skiRun;
            int           skiRunID;

            using (skiRunBusiness)
            {
                skiRuns  = skiRunBusiness.SelectAll();
                skiRunID = ConsoleView.GetSkiRunID(skiRuns);
                skiRun   = skiRunBusiness.SelectById(skiRunID);
                skiRun   = ConsoleView.UpdateSkiRun(skiRun);
                skiRunBusiness.Update(skiRun);
            }
        }
Example #8
0
        private static void QuerySkiRunsByVertical()
        {
            SkiRunBusiness skiRunBusiness = new SkiRunBusiness(skiRunRepository);

            List <SkiRun> matchingSkiRuns;
            int           minimumVertical;
            int           maximumVertical;

            ConsoleView.GetVerticalQueryMinMaxValues(out minimumVertical, out maximumVertical);

            using (skiRunBusiness)
            {
                matchingSkiRuns = skiRunBusiness.QueryByVertical(minimumVertical, maximumVertical);
            }

            ConsoleView.DisplayQueryResults(matchingSkiRuns);
            ConsoleView.DisplayContinuePrompt();
        }
Example #9
0
        private static void DisplaySkiRunDetail()
        {
            SkiRunBusiness skiRunBusiness = new SkiRunBusiness(skiRunRepository);

            List <SkiRun> skiRuns;
            SkiRun        skiRun;
            int           skiRunID;

            using (skiRunBusiness)
            {
                skiRuns  = skiRunBusiness.SelectAll();
                skiRunID = ConsoleView.GetSkiRunID(skiRuns);
                skiRun   = skiRunBusiness.SelectById(skiRunID);
            }

            ConsoleView.DisplaySkiRun(skiRun);
            ConsoleView.DisplayContinuePrompt();
        }
Example #10
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();
                }
            }
        }
Example #11
0
        private static void DeleteSkiRun()
        {
            SkiRunBusiness skiRunBusiness = new SkiRunBusiness(skiRunRepository);

            List <SkiRun> skiRuns;
            int           skiRunID;
            string        message;

            using (skiRunBusiness)
            {
                skiRuns  = skiRunBusiness.SelectAll();
                skiRunID = ConsoleView.GetSkiRunID(skiRuns);
                skiRunBusiness.Delete(skiRunID);
            }

            ConsoleView.DisplayReset();

            // TODO refactor to confirm
            message = String.Format("Ski Run ID: {0} had been deleted.", skiRunID);

            ConsoleView.DisplayMessage(message);
            ConsoleView.DisplayContinuePrompt();
        }
Example #12
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);
                }
            }
        }