public static int ValidateIntegerResponse(string promptMessage, string userResponse) { int userResponseInteger = 0; while (!(int.TryParse(userResponse, out userResponseInteger))) { ConsoleView.DisplayReset(); ConsoleView.DisplayMessage(""); ConsoleView.DisplayMessage("It appears you have not entered a valid integer."); ConsoleView.DisplayMessage(""); ConsoleView.DisplayPromptMessage(promptMessage); userResponse = Console.ReadLine(); } return(userResponseInteger); }
private static void QueryByDateBorn() { GreatPeopleRepositorySQL greatPeopleRepository = new GreatPeopleRepositorySQL(); IEnumerable <GreatPeople> matchingDate = new List <GreatPeople>(); int minimumDate; int maximumDate; ConsoleView.GetDateMinMaxValues(out minimumDate, out maximumDate); using (greatPeopleRepository) { matchingDate = greatPeopleRepository.QueryByDateBorn(minimumDate, maximumDate); } ConsoleView.DisplayQueryResults(matchingDate); Console.WriteLine(); Console.WriteLine(); Console.ForegroundColor = System.Drawing.Color.LawnGreen; ConsoleView.DisplayContinuePromptInvisible(); }
public static void GetDateMinMaxValues(out int minimumDate, out int maximumDate) { minimumDate = 0; maximumDate = 0; ConsoleView.DisplayReset(); ConsoleView.DisplayMessage(""); Console.ForegroundColor = System.Drawing.Color.CadetBlue; Console.WriteLine(ConsoleUtil.Center(" Filter Great People By Year Born", 92)); System.Console.WriteLine(); System.Console.WriteLine("************************************************************************************************************************"); ConsoleView.DisplayMessage(""); Console.ResetColor(); Console.ForegroundColor = System.Drawing.Color.DarkGoldenrod; ConsoleView.DisplayPromptMessage("Enter the minimum date: "); Console.ForegroundColor = System.Drawing.Color.Firebrick; string userResponse = Console.ReadLine(); if (userResponse != "") { minimumDate = ConsoleUtil.ValidateIntegerResponse("Please enter the minimum date using only numbers:", userResponse); } Console.ResetColor(); ConsoleView.DisplayMessage(""); Console.ForegroundColor = System.Drawing.Color.Gold; ConsoleView.DisplayPromptMessage("Enter the maximum date: "); Console.ForegroundColor = System.Drawing.Color.IndianRed; string userResponse2 = Console.ReadLine(); if (userResponse2 != "") { Console.ForegroundColor = System.Drawing.Color.Crimson; } maximumDate = ConsoleUtil.ValidateIntegerResponse("Please enter the maximum date.", userResponse2); ConsoleView.DisplayMessage(""); Console.ForegroundColor = System.Drawing.Color.PaleGoldenrod; ConsoleView.DisplayMessage(string.Format("You have entered {0} as the minimum date and {1} as the maximum date.", (object)minimumDate, (object)maximumDate)); ConsoleView.DisplayMessage(""); Console.ForegroundColor = System.Drawing.Color.MediumVioletRed; ConsoleView.DisplayContinuePrompt(); }
private static void DeleteGreatPerson() { GreatPeopleRepositorySQL greatPeopleRepository = new GreatPeopleRepositorySQL(); List <GreatPeople> greatPeople = greatPeopleRepository.SelectAll(); GreatPeople greatPerson = new GreatPeople(); int greatPersonID; string message; greatPersonID = ConsoleView.GetGreatPersonID(greatPeople); using (greatPeopleRepository) { greatPeopleRepository.Delete(greatPersonID); } ConsoleView.DisplayReset(); message = String.Format("Great Person ID: {0} had been deleted.", greatPersonID); ConsoleView.DisplayMessage(message); ConsoleView.DisplayContinuePromptInvisible(); }
private static void DeleteFirearm() { FirearmRepositorySQL firearmRepository = new FirearmRepositorySQL(); List <Firearm> firearms = firearmRepository.SelectAll(); Firearm firearm = new Firearm(); int firearmID; string message; firearmID = ConsoleView.GetFirearmID(firearms); using (firearmRepository) { firearmRepository.Delete(firearmID); } ConsoleView.DisplayReset(); message = String.Format("Firearm ID: {0} had been deleted.", firearmID); ConsoleView.DisplayMessage(message); ConsoleView.DisplayContinuePrompt(); }
public static int ValidateIntegerResponse(string promptMessage, string userResponse) { int userResponseInteger = 0; while (!(int.TryParse(userResponse, out userResponseInteger))) { ConsoleView.DisplayReset(); ConsoleView.DisplayMessage(" "); Console.ForegroundColor = System.Drawing.Color.OrangeRed; System.Console.WriteLine(); System.Console.WriteLine(); System.Console.WriteLine(); System.Console.WriteLine(); System.Console.WriteLine(); System.Console.WriteLine(); System.Console.WriteLine(); System.Console.WriteLine(); System.Console.WriteLine(); System.Console.WriteLine(); System.Console.WriteLine(); System.Console.WriteLine(); System.Console.WriteLine(); System.Console.WriteLine(); System.Console.WriteLine(); ConsoleView.DisplayMessage("*It appears you have not entered a valid integer.*"); System.Console.WriteLine(); Console.ForegroundColor = System.Drawing.Color.DarkOrange; ConsoleView.DisplayMessage(" "); ConsoleView.DisplayPromptMessage(promptMessage); userResponse = Console.ReadLine(); } return(userResponseInteger); }