Пример #1
0
        private static void UpdateSkiRun()
        {
            SkiRunRepositoryXML_DS skiRunRepository = new SkiRunRepositoryXML_DS();
            List <SkiRun>          skiRuns          = skiRunRepository.SelectAllRuns();
            SkiRun skiRun = new SkiRun();
            int    skiRunID;

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

            skiRunID = ConsoleView.GetSkiRunID(skiRuns);

            using (skiRunRepository)
            {
                skiRun = skiRunRepository.SelectByID(skiRunID);
            }

            skiRun = ConsoleView.UpdateSkiRun(skiRun);

            using (skiRunRepository)
            {
                skiRunRepository.UpdateSkiRun(skiRun);
            }
        }
Пример #2
0
        private static void DeleteSkiRun()
        {
            SkiRunRepositoryXML_DS skiRunRepository = new SkiRunRepositoryXML_DS();
            List <SkiRun>          skiRuns;
            SkiRun skiRun = new SkiRun();
            int    skiRunID;
            string message;

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

            skiRunID = ConsoleView.GetSkiRunID(skiRuns);

            using (skiRunRepository)
            {
                skiRunRepository.DeleteSkiRun(skiRunID);
            }

            ConsoleView.DisplayReset();

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

            ConsoleView.DisplayMessage(message);
            ConsoleView.DisplayContinuePrompt();
        }
Пример #3
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);
            }
        }
Пример #4
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();
        }
Пример #5
0
        private static void DisplaySkiRunDetail()
        {
            SkiRunRepositoryXML_DS skiRunRepository = new SkiRunRepositoryXML_DS();
            List <SkiRun>          skiRuns;
            SkiRun skiRun = new SkiRun();
            int    skiRunID;

            using (skiRunRepository)
            {
                skiRuns = skiRunRepository.SelectAllRuns();
            }
            skiRunID = ConsoleView.GetSkiRunID(skiRuns);

            using (skiRunRepository)
            {
                skiRun = skiRunRepository.SelectByID(skiRunID);
            }

            ConsoleView.DisplaySkiRun(skiRun);
            ConsoleView.DisplayContinuePrompt();
        }
Пример #6
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();
        }
Пример #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    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();
        }