Ejemplo n.º 1
0
        public Clientt Register(Clientt c, IConsole console, Metode m)
        {
            while (true)
            {
                console.WriteLine("1.Subscribe to an existing Lobby.\n2.Crate your own lobby.\n//Press 1 or 2 on your keyboard//");
                var cki = console.ReadKey();

                if (cki.Key == ConsoleKey.D1 || cki.Key == ConsoleKey.NumPad1)
                {
                    if (m.server.lista_klijentskih_redova.Count != 0)
                    {
                        c = m.Subscribe(pfs, c.Naziv_trenutnog_lobbyja, c.Id, c.Model, c.Naziv_klijenta, false);
                        m.server.repository.Models.Add(c.Model);
                        m.server.repository.Clients.Add(c);
                        m.server.repository.SaveChanges();
                        return(c);
                    }
                    else
                    {
                        console.WriteLine("Moras create prvo!");
                    }
                }
                else if (cki.Key == ConsoleKey.D2 || cki.Key == ConsoleKey.NumPad2)
                {
                    m.Create(pfc, c);

                    m.server.repository.Models.Add(c.Model);
                    m.server.repository.Clients.Add(c);
                    m.server.repository.SaveChanges();
                    return(c);
                }
                else
                {
                    console.WriteLine("Wrong input, try again!");
                }
            }
        }
Ejemplo n.º 2
0
        public void Menu(IConsole console, Metode m)
        {
            Clientt c = m.server.Kreiraj_klijenta(console);

            Register(c, console, m);


            while (true)
            {
                console.WriteLine("________---MAIN MENU---________");
                console.WriteLine("Trenutni klijent: " + c.Naziv_klijenta + "/" + c.Naziv_trenutnog_lobbyja + "/" + c.Id);
                foreach (Clientt cds in c.Model.Clients)
                {
                    console.WriteLine(cds.Naziv_klijenta);
                }
                console.WriteLine("1.Resubscribe");
                console.WriteLine("2.Create");
                console.WriteLine("3.Update");
                console.WriteLine("4.Your current data");
                console.WriteLine("5.Create new Client.");
                console.WriteLine("6.Choose client");

                var cki = Console.ReadKey();

                switch (cki.Key)
                {
                case ConsoleKey.D1:
                    if (m.server.lista_klijentskih_redova.Count != 1)
                    {
                        c = m.Subscribe(pfs, c.Naziv_trenutnog_lobbyja, c.Id, c.Model, c.Naziv_klijenta, true);
                        m.server.repository.SaveChanges();
                    }
                    break;

                case ConsoleKey.D2:
                    m.Create(pfc, c);
                    m.server.repository.SaveChanges();
                    break;

                case ConsoleKey.D3:
                    m.Update(pfu, c);
                    break;

                case ConsoleKey.D4:
                    m.ShowClientData(c);
                    break;

                case ConsoleKey.D5:
                    c = m.server.Kreiraj_klijenta(console);
                    c = Register(c, console, m);
                    break;

                case ConsoleKey.D6:
                    c = m.server.IzaberiClienta(console, c);
                    break;

                default:
                    console.WriteLine("Wrong input. Try again!");
                    break;
                }
            }
        }