public static void BrisanjeEmisije() { List <TvProgram> secondList = new List <TvProgram>(); using (var stream = new System.IO.MemoryStream()) { var binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); binaryFormatter.Serialize(stream, TvKuca.Instance.TvProgrami); //serialize to stream stream.Position = 0; //deserialize from stream. secondList = binaryFormatter.Deserialize(stream) as List <TvProgram>; } Console.WriteLine(secondList.Count); var odabirEmisije = 0; Console.WriteLine("Unesite traženi id emisije"); odabirEmisije = int.Parse(Console.ReadLine()); TvKucaMemory m = new TvKucaMemory(); m.Memento = TvKuca.Instance.SpremiRaspored(secondList); m.Memento.DatumPohrane = DateTime.Now; m.Memento.IdPohrane = UcitaniPodaci.ListaPohranjivanja.Count + 1; UcitaniPodaci.ListaPohranjivanja.Add(m); foreach (var program in TvKuca.Instance.TvProgrami) { foreach (var VARIABLE in program.DohvatiDjecu()) { DnevniRaspored dan = VARIABLE as DnevniRaspored; var odabranaEmisija = dan.DohvatiDjecu().Find(c => ((EmisijaRasporeda)c).UnikatniID == odabirEmisije); dan.Obrisi(odabranaEmisija); } } Console.WriteLine(UcitaniPodaci.ListaPohranjivanja.Count); }
//opcija 6 public static void BrisanjeEmisije() { try { DefaultView pogled = new DefaultView(); BrojivView brojiviPogled = new BrojivView(); List <TvProgram> secondList = new List <TvProgram>(); using (var stream = new MemoryStream()) { var binaryFormatter = new BinaryFormatter(); binaryFormatter.Serialize(stream, TvKuca.Instance.TvProgrami); stream.Position = 0; secondList = binaryFormatter.Deserialize(stream) as List <TvProgram>; } Console.WriteLine(secondList.Count); var odabirEmisije = 0; if (trenutniPogled == 1) { pogled.IspisOdabiraIDEmisije(); } if (trenutniPogled == 2) { brojiviPogled.IspisOdabiraIDEmisije(); } odabirEmisije = int.Parse(Console.ReadLine()); TvKucaMemory m = new TvKucaMemory(); m.Memento = TvKuca.Instance.SpremiRaspored(secondList); m.Memento.DatumPohrane = DateTime.Now; m.Memento.IdPohrane = UcitaniPodaci.ListaPohranjivanja.Count + 1; UcitaniPodaci.ListaPohranjivanja.Add(m); foreach (var program in TvKuca.Instance.TvProgrami) { foreach (var VARIABLE in program.DohvatiDjecu()) { DnevniRaspored dan = VARIABLE as DnevniRaspored; var odabranaEmisija = dan.DohvatiDjecu().Find(c => ((EmisijaRasporeda)c).UnikatniID == odabirEmisije); dan.Obrisi(odabranaEmisija); } } Console.WriteLine(UcitaniPodaci.ListaPohranjivanja.Count); } catch (Exception) { Console.WriteLine("Greška"); } }