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(); }
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(); }
private static void DeleteSkiRun() { SkiRunRepositoryXML_DS skiRunRepository = new SkiRunRepositoryXML_DS(); List <SkiRun> skiRuns = skiRunRepository.SelectAllRuns(); SkiRun skiRun = new SkiRun(); int skiRunID; string message; 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(); }
/// <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); } } }
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(); }
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(); }
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(); }