Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var dziekanatDB = new DziekanatDbContext();

            do
            {
                Console.Clear();
                Console.WriteLine("1. Add new student");
                Console.WriteLine("2. Clear whole database");
                Console.WriteLine("3. Show whole content");
                Console.WriteLine("4. Remove last added student");
                Console.WriteLine("5. Find student by Id");
                Console.WriteLine("6. Find student by name");
                Console.WriteLine("7. Find student by speciality");
                Console.WriteLine("8. Find student by deficit");
                Console.WriteLine("9. Exit");
                Console.WriteLine("Chose one option");
            } while (MainMenu(dziekanatDB));
        }
Ejemplo n.º 2
0
        static bool MainMenu(DziekanatDbContext dziekanatDB)
        {
            switch (Console.ReadLine())
            {
            case "1":
                Console.WriteLine("Insert new student");
                dziekanatDB.Students.Add(dziekanatDB.AddDataToBase());
                dziekanatDB.SaveChanges();
                Console.WriteLine("Press enter to return");
                Console.ReadLine();
                return(true);

            case "2":
                dziekanatDB.ClearBase();
                Console.WriteLine("Base Cleared");
                Console.WriteLine("Press enter to return");
                Console.ReadLine();
                return(true);

            case "3":
                dziekanatDB.ShowDataBaseContent();
                Console.WriteLine("Press enter to return");
                Console.ReadLine();
                return(true);

            case "4":
                dziekanatDB.RemoveLast();
                Console.WriteLine("Element removed");
                Console.WriteLine("Press enter to return");
                Console.ReadLine();
                return(true);

            case "5":
                Console.WriteLine("Find by Id: ");
                dziekanatDB.FindById(Convert.ToInt32(Console.ReadLine()));
                Console.WriteLine("Press enter to return");
                Console.ReadLine();
                return(true);

            case "6":
                Console.WriteLine("Find students' with given name: ");
                dziekanatDB.FindByName(Console.ReadLine());
                Console.WriteLine("Press enter to return");
                Console.ReadLine();
                return(true);

            case "7":
                Console.WriteLine("Find students' with given speciality: ");
                dziekanatDB.FindBySpeciality(Console.ReadLine());
                Console.WriteLine("Press enter to return");
                Console.ReadLine();
                return(true);

            case "8":
                Console.WriteLine("Find students' with given deficit: ");
                dziekanatDB.FindByDeficit(Convert.ToInt32(Console.ReadLine()));
                Console.WriteLine("Press enter to return");
                Console.ReadLine();
                return(true);

            case "9":
                return(false);

            default:
                Console.WriteLine("Error: option not found");
                Console.WriteLine("\nPress enter to return");
                Console.ReadLine();
                return(true);
            }
        }