Beispiel #1
0
        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));
                });
            }
        }