/// <summary> /// Representing method used for load data /// </summary> public static void LoadData() { string lineDrzava; string lineWorldCup; StreamReader citacDrzava = File.OpenText(lokacija + "\\" + "data" + "\\" + "drzave.csv"); while ((lineDrzava = citacDrzava.ReadLine()) != null) { Drzava drzava = new Drzava(lineDrzava); listaDrzava.Add(drzava.ID, drzava); } citacDrzava.Close(); StreamReader citacSvetskihPrvenstava = File.OpenText(lokacija + "\\" + "data" + "\\" + "svetskaPrvenstva.csv"); while ((lineWorldCup = citacSvetskihPrvenstava.ReadLine()) != null) { SvetskoPrvenstvo worldCup = new SvetskoPrvenstvo(lineWorldCup, listaDrzava); listaSvetskihPrvenstva.Add(worldCup.ID, worldCup); } citacSvetskihPrvenstava.Close(); }
/// <summary> /// Representing method which allow user to add or change world cup /// </summary> public static void AddOrChangeWorldCup() { Console.WriteLine("1.Add"); Console.WriteLine("2.Change"); Console.Write("Options:"); int option = Helper.CheckID(); switch (option) { case 1: Console.Clear(); Console.Write("Enter the name of the world cup:"); string naziv = Helper.CheckString(); Console.Clear(); Console.Write("Enter the year of the world cup:"); int yearAdd = Helper.CheckID(); Console.Clear(); WriteAllCountrys(); Console.Write("Enter the id of the \"Domacin\":"); int idDrzaveDomacina = Helper.CheckID(); if (listaDrzava.ContainsKey(idDrzaveDomacina)) { Drzava drzavaDomacin = listaDrzava[idDrzaveDomacina]; SvetskoPrvenstvo svetskoPrvenstvoAdd = new SvetskoPrvenstvo { ID = listaSvetskihPrvenstva.Keys.Max() + 1, Naziv = naziv, Domacin = drzavaDomacin, Godina = yearAdd }; listaSvetskihPrvenstva.Add(svetskoPrvenstvoAdd.ID, svetskoPrvenstvoAdd); Console.Clear(); Console.WriteLine("Svetsko prvenstvo je uspesno dodato!"); } else { Console.WriteLine("That ID does not exits!"); } SaveWorldCups(); Console.WriteLine("Press any key to continue..."); Console.ReadLine(); Console.Clear(); break; case 2: Console.Clear(); WriteAllWorldCups(); Console.Write("Enter the ID of the world cup which you want edit:"); int idSelect = Helper.CheckID(); Console.Clear(); if (listaSvetskihPrvenstva.ContainsKey(idSelect)) { SvetskoPrvenstvo svetskoPrvenstvo = listaSvetskihPrvenstva[idSelect]; Console.Write("Enter the name of the world cup:"); string nazivEdit = Helper.CheckString(); Console.Clear(); Console.Write("Enter the year of the world cup:"); int yearEdit = Helper.CheckID(); Console.Clear(); WriteAllCountrys(); Console.Write("Enter the ID of the \"Domacin\":"); int idDomacin = Helper.CheckID(); Console.Clear(); if (listaDrzava.ContainsKey(idDomacin)) { Drzava drzavaDomacinEdit = listaDrzava[idDomacin]; svetskoPrvenstvo = new SvetskoPrvenstvo { ID = idSelect, Naziv = nazivEdit, Godina = yearEdit, Domacin = drzavaDomacinEdit }; listaSvetskihPrvenstva[idSelect] = svetskoPrvenstvo; SaveWorldCups(); Console.Clear(); Console.WriteLine("Svetsko prvenstvo je uspesno dodato!"); } else { Console.WriteLine("That ID of country does not exits!"); } } else { Console.WriteLine("That ID does not exits!"); } Console.WriteLine("Press any key to continue..."); Console.ReadLine(); break; default: Console.WriteLine("That options does not exits!"); break; } }