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!"); } } }
static void Main(string[] args) { Repository repo = new Repository("myConnectionString"); repo.Database.CreateIfNotExists(); ConsoleWrapper cw = new ConsoleWrapper(); QueueFactory qf = new QueueFactory(); MyTupleFactory mtf = new MyTupleFactory(); ClientFactory cf = new ClientFactory(); Pomocne_funkcijeSubscribe pfs = new Pomocne_funkcijeSubscribe(mtf, qf); Pomocne_funkcijeCreate pfc = new Pomocne_funkcijeCreate(mtf, qf); Pomocne_funkcijeUpdate.Pomocne_funkcijeUpdate pfu = new Pomocne_funkcijeUpdate.Pomocne_funkcijeUpdate(); Serverr server = new Serverr(cf, repo); Metode metode = new Metode(server, cw); Meni meni = new Meni(pfc, pfs, pfu); Model m = new Model(); Clientt c = new Clientt(); server.IscitajIzBazeNaPocetku(); meni.Menu(cw, metode); }
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; } } }