public void DeleteExistingBicycle()
        {
            try
            {
                var bicycle = new GetAllBicycles();
                bicycle.GetAllBicyclesInfo();

                Console.WriteLine("Choose Bicycle to delete by entering Bicycle Id: ");
                var userinput = Convert.ToInt32(Console.ReadLine());

                var getBicycle      = new ReturnBicycle();
                var bicycleToDelete = getBicycle.Return_Bicycle(userinput);

                if (bicycleToDelete == null)
                {
                    Console.WriteLine("No bicycle was found..");
                    Visuals.ReturnToMainMenu();
                }

                _bicycleRentalDbContext
                .Bicycles
                .Remove(bicycleToDelete);

                _bicycleRentalDbContext
                .SaveChanges();

                Console.WriteLine($"Existing Bicycles with Bicycle Id: {bicycleToDelete.Bicycle_id} deleted successfully!");
            }

            catch (Exception ex)
            {
                Console.WriteLine($"You messed up! {ex}");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get specific bicycle info
        /// </summary>
        public void GetSpecificBicycleInfo()
        {
            try
            {
                var bicycles = new GetAllBicycles();
                Console.WriteLine($"Here are all existing Bicycles:\n");
                bicycles.GetAllBicyclesInfo();

                Console.WriteLine($"\nChoose specific Bicycle to view by entering Bicycle Id ");
                var userInput = Convert.ToInt32(Console.ReadLine());
                var bicycle   = _bicycleRentalDbContext.Bicycles.Find(userInput);

                if (bicycle == null)
                {
                    Console.WriteLine("No bicycle was found..");
                    Visuals.ReturnToMainMenu();
                }

                Console.Clear();

                Console.WriteLine($"Your specific Bicycle: ");
                Console.WriteLine($"Bicycle_id: {bicycle.Bicycle_id}");
                Console.WriteLine($"Brand_id: {bicycle.Brand_id}");
                Console.WriteLine($"Frame_number: {bicycle.Frame_number}");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"You messed up! {ex}");
            }
        }
Ejemplo n.º 3
0
        /// <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;
            }
        }
Ejemplo n.º 4
0
        public void UpdateExistingBicycle()
        {
            try
            {
                var bicycle = new GetAllBicycles();
                bicycle.GetAllBicyclesInfo();

                Console.WriteLine("Choose bicycle to update by entering Bicycle Id: ");
                var userinput = Convert.ToInt32(Console.ReadLine());

                var getBicycle      = new ReturnBicycle();
                var bicycleToUpdate = getBicycle.Return_Bicycle(userinput);

                if (bicycleToUpdate == null)
                {
                    Console.WriteLine("No bicycle was found..");
                    Visuals.ReturnToMainMenu();
                }

                Console.WriteLine("Change bicycle information");
                Console.WriteLine("");
                Console.WriteLine("Update Frame number");
                bicycleToUpdate.Frame_number = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Update Brand id");
                bicycleToUpdate.Brand_id = Convert.ToInt32(Console.ReadLine());


                _bicycleRentalDbContext
                .Bicycles
                .Update(bicycleToUpdate);

                _bicycleRentalDbContext
                .SaveChanges();

                Console.WriteLine("Existing bicicle updated successfully!");
                Console.WriteLine("");
                Console.WriteLine("---------------------------------------");
                Console.WriteLine($"Bicycle Bicycle_id: {bicycleToUpdate.Bicycle_id}");
                Console.WriteLine($"Bicycle Frame_number: {bicycleToUpdate.Frame_number}");
                Console.WriteLine($"Bicycle Brand_id: {bicycleToUpdate.Brand_id}");
                Console.WriteLine("---------------------------------------");
            }

            catch (Exception ex)
            {
                Console.WriteLine($"You messed up! {ex}");
            }
        }