private static ushort FindCarByID() { Console.Write("Enter car ID number : >"); string checkId = (Console.ReadLine()); if (ushort.TryParse(checkId, out ushort getId)) { var carToUpdate = _carRepo.GetCarById(getId); if (carToUpdate == null) { Console.WriteLine("ERROR: Check the ID number and try again.\n\n"); MenuOps.MenuSelections(); } Console.WriteLine($"\nSelected vehicle {carToUpdate.Make} {carToUpdate.Model}\n"); } else { Console.WriteLine("ERROR: Check the ID number and try again.\n\n"); MenuOps.MenuSelections(); } return(getId); }
public void Run() { SeedThis(); MenuOps.MenuSelections(); }
private static void AddCarDetails(Car newItem, ushort carNum) { Console.Write("Enter a car make > "); string carMake = (Console.ReadLine()); Console.Write("Enter a model > "); string carModel = (Console.ReadLine()); Console.Write("Enter engine type > "); string carEngine = (Console.ReadLine()); bool numberCheck = true; double carCollision = 0.0; do { Console.Write("Enter reported collision percentage in decimal format (e.g. 42% = .42) > "); string verifyInput = (Console.ReadLine()); if (double.TryParse(verifyInput, out double userInput)) { carCollision = userInput; numberCheck = false; } else { Console.WriteLine("ERROR: Needs to be in decial format (e.g. 0.10).\n\n"); numberCheck = true; } } while (numberCheck); //Console.Write("Enter reported personal injury percentage > "); //double carInjury = Convert.ToDouble(Console.ReadLine()); double carComprehensive = 0.0; do { Console.Write("Enter reported comprehensive percentage in decimal format (e.g. 42% = .42) > "); string verifyInput = (Console.ReadLine()); if (double.TryParse(verifyInput, out double userInput)) { carComprehensive = userInput; numberCheck = false; } else { Console.WriteLine("ERROR: Needs to be in decial format (e.g. 0.10).\n\n"); numberCheck = true; } } while (numberCheck); double carInjury = 0.0; do { Console.Write("Enter reported personal injury percentage in decimal format (e.g. 42% = .42) > "); string verifyInput = (Console.ReadLine()); if (double.TryParse(verifyInput, out double userInput)) { carInjury = userInput; numberCheck = false; } else { Console.WriteLine("ERROR: Needs to be in decial format (e.g. 0.10).\n\n"); numberCheck = true; } } while (numberCheck); Console.Clear(); Console.WriteLine(); Console.WriteLine($"ID # {carNum}: {carMake} {carModel}\n " + $"Collision: {carCollision}\t Comprehensive: {carComprehensive}\t Personal Injury: {carInjury}\n"); Console.Write("Confirm: Is this information correct?\n (y/n) > "); string response = (Console.ReadLine().ToLower()); if (response == "y") { newItem.Id = carNum; newItem.Make = carMake; newItem.Model = carModel; newItem.Propulsion = carEngine; newItem.Collision = carCollision; newItem.Comprehensive = carComprehensive; newItem.PersonalInjury = carInjury; } else { Console.WriteLine("Invalid response. Changes not saved. Please try again.\n\n"); MenuOps.MenuSelections(); } }//AddCarDetails()