public void DeleteExistingBicycleBrand() { try { var bicycleBrand = new GetAllBicycleBrands(); bicycleBrand.GetAllBicycleBrandsInfo(); Console.WriteLine("Choose Bicycle Brand to delete by entering Brand Id: "); var userinput = Convert.ToInt32(Console.ReadLine()); var getBicycleBrand = new ReturnBicycleBrand(); var bicycleBrandToDelete = getBicycleBrand.Return_BicycleBrand(userinput); if (bicycleBrandToDelete == null) { Console.WriteLine("No Bicycle Brand was found.."); Visuals.ReturnToMainMenu(); } _bicycleRentalDbContext .Bicycle_brands .Remove(bicycleBrandToDelete); _bicycleRentalDbContext .SaveChanges(); Console.WriteLine($"Existing Bicycle brand with Brand id: {bicycleBrandToDelete.Brand_id} deleted successfully!"); } catch (Exception ex) { Console.WriteLine($"You messed up! {ex}"); } }
/// <summary> /// Get specific bicycle brand info /// </summary> public void GetSpecificBicycleBrandInfo() { try { var bicycleBrands = new GetAllBicycleBrands(); Console.WriteLine($"Here are all existing Bicycle Brands:\n"); bicycleBrands.GetAllBicycleBrandsInfo(); Console.WriteLine($"\nChoose specific Bicycle Brand to view by entering Bicycle Brand Id "); var userInput = Convert.ToInt32(Console.ReadLine()); var bicycleBrand = _bicycleRentalDbContext.Bicycle_brands.Find(userInput); if (bicycleBrand == null) { Console.WriteLine("No bicycleBrand was found.."); Visuals.ReturnToMainMenu(); } Console.Clear(); Console.WriteLine($"Your specific Bicycle Brand: "); Console.WriteLine($"Brand_id: {bicycleBrand.Brand_id}"); Console.WriteLine($"Bicycle_type: {bicycleBrand.Bicycle_type}"); Console.WriteLine($"Bicycle_name: {bicycleBrand.Bicycle_name}"); Console.WriteLine($"Avilability: {bicycleBrand.Avilability}"); } catch (Exception ex ) { Console.WriteLine($"You messed up! {ex}"); } }
public void UpdateExistingBicycleBrand() { try { var bicycleBrand = new GetAllBicycleBrands(); bicycleBrand.GetAllBicycleBrandsInfo(); Console.WriteLine("Choose bicycle brand to update by entering Bicycle Id: "); var userinput = Convert.ToInt32(Console.ReadLine()); var getBicycleBrand = new ReturnBicycleBrand(); var bicycleBrandToUpdate = getBicycleBrand.Return_BicycleBrand(userinput); if (bicycleBrandToUpdate == null) { Console.WriteLine("No Bicycle Brand was found.."); Visuals.ReturnToMainMenu(); } Console.WriteLine("Change bicycle brand information"); Console.WriteLine(""); Console.WriteLine("Update Bicycle type"); bicycleBrandToUpdate.Bicycle_type = Console.ReadLine(); Console.WriteLine("Update Bicycle name"); bicycleBrandToUpdate.Bicycle_name = Console.ReadLine(); Console.WriteLine("Update Avilability"); bicycleBrandToUpdate.Avilability = Convert.ToBoolean(Console.ReadLine()); _bicycleRentalDbContext .Bicycle_brands .Update(bicycleBrandToUpdate); _bicycleRentalDbContext .SaveChanges(); Console.WriteLine("Existing bicicle brand: updated successfully!"); Console.WriteLine(""); Console.WriteLine("---------------------------------------"); Console.WriteLine($"Bicycle brand Bicycle_type: {bicycleBrandToUpdate.Bicycle_type}"); Console.WriteLine($"Bicycle brand Bicycle_name: {bicycleBrandToUpdate.Bicycle_name}"); Console.WriteLine($"Bicycle brand Avilability: {bicycleBrandToUpdate.Avilability}"); Console.WriteLine("---------------------------------------"); } catch (Exception ex) { Console.WriteLine($"You messed up! {ex}"); } }
/// <summary> /// Choose this to enter the Show All Information menu /// </summary> public static void ShowAllInformation() { var bicycles = new GetAllBicycles(); var customers = new GetAllCustomers(); var bicycleBrands = new GetAllBicycleBrands(); var filteredCustomer = new GetFilteredCustomers(); Console.Clear(); Console.WriteLine("1: Show all Bicycles"); Console.WriteLine("2: Show all Customers"); Console.WriteLine("3: Show all Bicycle Brands"); Console.WriteLine("4: Show all Customers who's first name starts with the letter 'A'"); Console.WriteLine(""); var userChoice = Console.ReadLine(); switch (userChoice) { case "1": bicycles.GetAllBicyclesInfo(); ReturnToMainMenu(); break; case "2": customers.GetAllCustomersInfo(); ReturnToMainMenu(); break; case "3": bicycleBrands.GetAllBicycleBrandsInfo(); ReturnToMainMenu(); break; case "4": filteredCustomer.GetFilteredCustomersInfo(); ReturnToMainMenu(); break; default: Console.Clear(); Console.WriteLine("Input does not exist!.. Press any key except the one you pressed to get here!.. try again!.. "); Console.ReadKey(); ShowAllInformation(); break; } }