private void InitData() { DatabasePZEntities context = new DatabasePZEntities(); var api = new ApiRequester(); Movie movie; foreach (var seans in context.SEANS) { movie = api.getAppMovie((int)seans.Id_film); var hours = new ObservableCollection <string>(); var rooms = new ObservableCollection <Room>(); string spotTable; int currentSpotNumber; foreach (var godziny in context.GODZINY.Where(id => id.Id_Seansu == seans.Id_seans)) { hours.Add(godziny.Godzina); var spots = new ObservableCollection <Spot>(); SALA room = godziny.SEANS.SALA; spotTable = godziny.Miejsca; for (int i = 0; i < room.Ilosc_wierszy; i++) { for (int j = 0; j < room.Ilosc_kolumn; j++) { currentSpotNumber = (i * (int)room.Ilosc_kolumn) + j; int isAvailable = Int32.Parse(spotTable[currentSpotNumber].ToString()); spots.Add(new Spot(isAvailable, j, i, currentSpotNumber + 1)); } } rooms.Add(new Room(room.Id_sala, spots, (int)room.Ilosc_kolumn, (int)room.Ilosc_wierszy)); } App.Current.Dispatcher.BeginInvoke((Action) delegate() { Seances.Add(new Seance(movie, rooms, hours, (DateTime)seans.Data_rozpoczecia, (DateTime)seans.Data_zakonczenia, seans.Id_seans)); }); } }
private void TimerTick(object sender, EventArgs e) { List <AccessToWebApi.Entities.Seance> seances = _seanceHttpClient.GetSeances().ToList(); /* * Необходимо проверить текущий список киносеансов и полученный от сервера на расхождения. * Если Списки разные,то текущий список обновляется. */ bool flagUpdateSeances = false;//Изначально обновлять не надо if (Seances.Count() == seances.Count()) { for (int i = 0; i < Seances.Count; i++) { if (Seances[i].Id != seances[i].Id) //есть расхождения { flagUpdateSeances = true; //обновляем break; } } } else { flagUpdateSeances = true;//обновляем } //Обновление текущего списка if (flagUpdateSeances) { Seances.Clear(); foreach (var seance in seances) { Seances.Add(new Model.Seance() { Id = seance.Id, Name = seance.Name, Start = seance.Start }); } } }