Exemplo n.º 1
0
        private static void ProcessInput()
        {
            if (CurrentMenu17455 == Menus.Izlaz)
            {
                System.Environment.Exit(0);
            }
            else if (CurrentMenu17455 == Menus.Main)
            {
                History17455.Push(CurrentMenu17455);
                if (Index17455 == 1)
                {
                    CurrentMenu17455 = Menus.RegDelKnjiga;
                }
                else if (Index17455 == 2)
                {
                    CurrentMenu17455 = Menus.RegDelClan;
                }
                else if (Index17455 == 3)
                {
                    CurrentMenu17455 = Menus.IznajmiVrati;
                }
                else if (Index17455 == 4)
                {
                    CurrentMenu17455 = Menus.Pretraga;
                }
                else if (Index17455 == 5)
                {
                    CurrentMenu17455 = Menus.Analiza;
                }
                else if (Index17455 == 6)
                {
                    CurrentMenu17455 = Menus.PrintClanova;
                }
                else if (Index17455 == 7)
                {
                    CurrentMenu17455 = Menus.PrintKnjiga;
                }
                else if (Index17455 == 8)
                {
                    CurrentMenu17455 = Menus.Naplati;
                }
                else if (Index17455 == 9)
                {
                    CurrentMenu17455 = Menus.Izlaz;
                }
            }
            else if (CurrentMenu17455 == Menus.RegDelKnjiga)
            {
                History17455.Push(CurrentMenu17455);
                if (Index17455 == 1)
                {
                    CurrentMenu17455 = Menus.RegKnjiga;
                }
                else if (Index17455 == 2)
                {
                    CurrentMenu17455 = Menus.DelKnjiga;
                }
                else if (Index17455 == 3)
                {
                    Nazad(true);
                }
            }
            else if (CurrentMenu17455 == Menus.RegKnjiga)
            {
                if (Index17455 == 1)
                {
                    History17455.Push(CurrentMenu17455);
                    Knjiga knjiga = new Knjiga();
                    knjiga.GetValid();
                    _bibliotekaManager17455.AddKnjiga(knjiga);
                    Nazad(true);
                }
                else if (Index17455 == 2)
                {
                    History17455.Push(CurrentMenu17455);
                    NaucniRad naucniRad = new NaucniRad();
                    naucniRad.GetValid();
                    _bibliotekaManager17455.AddKnjiga(naucniRad);
                    Nazad(true);
                }
                else if (Index17455 == 3)
                {
                    History17455.Push(CurrentMenu17455);
                    Strip strip = new Strip();
                    strip.GetValid();
                    _bibliotekaManager17455.AddKnjiga(strip);
                    Nazad(true);
                }
                else if (Index17455 == 4)
                {
                    Nazad(true);
                }
            }
            else if (CurrentMenu17455 == Menus.DelKnjiga)
            {
                History17455.Push(CurrentMenu17455);
                Console.Write("Unesite sifru knjige koju zelite izbrisati (q za nazad): ");

                string code = Console.ReadLine();
                if (code != "q")
                {
                    while (!_bibliotekaManager17455.RemoveKnjigaById(code))
                    {
                        Console.WriteLine("Knjiga sa tom sifrom ne postoji, unesite ponovo: ");
                        code = Console.ReadLine();
                        if (code == "q")
                        {
                            break;
                        }
                    }
                }

                Nazad(true);
            }
            else if (CurrentMenu17455 == Menus.RegDelClan)
            {
                History17455.Push(CurrentMenu17455);
                if (Index17455 == 1)
                {
                    CurrentMenu17455 = Menus.RegClan;
                }
                else if (Index17455 == 2)
                {
                    CurrentMenu17455 = Menus.DelClan;
                }
                else if (Index17455 == 3)
                {
                    Nazad(true);
                }
            }
            else if (CurrentMenu17455 == Menus.DelClan)
            {
                History17455.Push(CurrentMenu17455);
                Console.Write("Unesite sifru clana kojeg zelite izbrisati (q za nazad): ");

                string id = Console.ReadLine();
                if (id != "q")
                {
                    while (!_bibliotekaManager17455.RemoveClanById(id))
                    {
                        Console.WriteLine("Clan sa tom sifrom ne postoji, unesite ponovo (q za nazad): ");
                        id = Console.ReadLine();
                        if (id == "q")
                        {
                            break;
                        }
                    }
                }

                Nazad(true);
            }
            else if (CurrentMenu17455 == Menus.IznajmiVrati)
            {
                History17455.Push(CurrentMenu17455);
                if (Index17455 == 1)
                {
                    CurrentMenu17455 = Menus.IznKnjigu;
                }
                else if (Index17455 == 2)
                {
                    CurrentMenu17455 = Menus.VraKnjigu;
                }
                else if (Index17455 == 3)
                {
                    Nazad(true);
                }
            }
            else if (CurrentMenu17455 == Menus.Pretraga)
            {
                History17455.Push(CurrentMenu17455);
                if (Index17455 == 1)
                {
                    CurrentMenu17455 = Menus.PoISBN;
                }
                else if (Index17455 == 2)
                {
                    CurrentMenu17455 = Menus.PoNazivu;
                }
                else if (Index17455 == 3)
                {
                    CurrentMenu17455 = Menus.PoSifri;
                }
                else if (Index17455 == 4)
                {
                    CurrentMenu17455 = Menus.PoImenu;
                }
                else if (Index17455 == 5)
                {
                    Nazad(true);
                }
            }
            else if (CurrentMenu17455 == Menus.PrintKnjiga)
            {
                History17455.Push(CurrentMenu17455);
                _bibliotekaManager17455.PrintKnjige();
                Parser.Stall(true);
                Nazad(true);
            }
            else if (CurrentMenu17455 == Menus.PrintClanova)
            {
                History17455.Push(CurrentMenu17455);
                _bibliotekaManager17455.PrintClanova();
                Parser.Stall(true);
                Nazad(true);
            }
            else if (CurrentMenu17455 == Menus.IznKnjigu)
            {
                History17455.Push(CurrentMenu17455);
                Console.Write("Unesi sifru knjige: ");
                string knjigaId = Console.ReadLine();
                Console.Write("Unesi sifru clana: ");
                string clanId = Console.ReadLine();

                List <string> errorMessages = null;
                if (!_bibliotekaManager17455.Iznajmi(clanId, knjigaId, out errorMessages))
                {
                    Console.WriteLine("Nije moguce iznajmniti zato sto:");
                    foreach (string error in errorMessages)
                    {
                        Console.WriteLine(error);
                    }
                    Parser.Stall();
                }

                Nazad(true);
            }
            else if (CurrentMenu17455 == Menus.VraKnjigu)
            {
                History17455.Push(CurrentMenu17455);

                Console.Write("Unesi sifru clana: ");
                string clanId = Console.ReadLine();
                Console.Write("Unesi sifru knjige: ");
                string knjigaId = Console.ReadLine();

                if (!_bibliotekaManager17455.VratiKnjigu(clanId, knjigaId))
                {
                    Console.WriteLine("Nije moguce vratiti knjigu.");
                    Parser.Stall();
                }

                Nazad(true);
            }
            else if (CurrentMenu17455 == Menus.PoISBN)
            {
                History17455.Push(CurrentMenu17455);
                string isbn;

                while (!KnjigaValidator.IsISBNValid(isbn = Console.ReadLine()))
                {
                    if (isbn == "q")
                    {
                        break;
                    }
                    else
                    {
                        Console.Write("Unesite validan ISBN (q za nazad): ");
                    }
                }

                if (isbn != "q")
                {
                    Knjiga knjiga = _bibliotekaManager17455.SearchByISBN(isbn);

                    if (knjiga == null)
                    {
                        Console.WriteLine("Ne postoji knjiga sa tim ISBNom.");
                    }
                    else
                    {
                        Console.WriteLine("Rezultat pretrage:");
                        knjiga.Print();
                    }
                }

                Nazad(true);
            }
            else if (CurrentMenu17455 == Menus.PoSifri)
            {
                History17455.Push(CurrentMenu17455);
                Console.Write("Unesite sifru: ");
                string sifra  = Console.ReadLine();
                IClan  result = _bibliotekaManager17455.SearchClanBySifra(sifra);

                if (result == null)
                {
                    Console.WriteLine("Nije pronadjen clan sa tom sifrom.");
                }
                else
                {
                    result.Print();
                }
                Parser.Stall();

                Nazad(true);
            }
            else if (CurrentMenu17455 == Menus.PoImenu)
            {
                History17455.Push(CurrentMenu17455);
                Console.Write("Unesite ime clana: ");
                string       ime    = Console.ReadLine();
                List <IClan> result = _bibliotekaManager17455.SearchBy(x => ((User)x).Ime == ime);

                if (result.Count == 0)
                {
                    Console.WriteLine("Nije pronadjen clan sa tim imenom.");
                }
                else
                {
                    foreach (IClan clan in result)
                    {
                        clan.Print();
                    }
                }

                Parser.Stall();
                Nazad(true);
            }
            else if (CurrentMenu17455 == Menus.PoNazivu)
            {
                History17455.Push(CurrentMenu17455);
                string naziv = Console.ReadLine();

                if (naziv != "q")
                {
                    List <Knjiga> knjige = _bibliotekaManager17455.SearchByNaziv(naziv);

                    if (knjige == null)
                    {
                        Console.WriteLine("Ne postoji knjiga sa tim nazivom.");
                    }
                    else
                    {
                        Console.WriteLine("Rezultat pretrage:");
                        foreach (Knjiga knjiga in knjige)
                        {
                            knjiga.Print();
                            Console.WriteLine();
                        }
                    }
                }

                Nazad(true);
            }
            else if (CurrentMenu17455 == Menus.Analiza)
            {
                History17455.Push(CurrentMenu17455);

                _bibliotekaManager17455.Analyse();

                Parser.Stall();
                Nazad(true);
            }
            else if (CurrentMenu17455 == Menus.RegClan)
            {
                Console.WriteLine("Odaberite tip clana:");
                Console.WriteLine("1. Obicni insan");
                Console.WriteLine("2. Student (podaci o nivou studija studenta ce biti uneseni kasnije)");
                Console.WriteLine("3. Profesor");
                Console.WriteLine("4. Nazad");

                int index = Parser.GetNextNumber(true, 1, 4);

                if (index == 1)
                {
                    User user = new User();
                    user.PromptInput();
                    _bibliotekaManager17455.AddClan(user);
                    Nazad(true);
                }
                else if (index == 2)
                {
                    Student student = new Student();
                    student.PromptInput();
                    _bibliotekaManager17455.AddClan(student);
                    Nazad(true);
                }
                else if (index == 3)
                {
                    Profesor profesor = new Profesor();
                    profesor.PromptInput();
                    _bibliotekaManager17455.AddClan(profesor);
                    Nazad(true);
                }
                else if (index == 4)
                {
                    Nazad(true);
                }
            }
            else if (CurrentMenu17455 == Menus.KnjigaInput)
            {
                Knjiga knjiga = new Knjiga();
                knjiga.GetValid();

                _bibliotekaManager17455.AddKnjiga(knjiga);
                Nazad(true);
            }
            else if (CurrentMenu17455 == Menus.Naplati)
            {
                History17455.Push(CurrentMenu17455);
                var bannedList = _bibliotekaManager17455.Naplati();

                if (bannedList?.Count > 0)
                {
                    Console.WriteLine("Sljedeci useri vise ne mogu korisiti usluge biblioteke:");
                    foreach (var user in bannedList)
                    {
                        user.Print();
                        Console.WriteLine();
                    }
                    Parser.Stall();
                }

                Nazad(true);
            }

            Console.Clear();
        }