Ejemplo n.º 1
0
        /// <summary>
        /// Обновление информации о свободных местах в данном вагоне после покупки билета
        /// </summary>
        private void UpdateWagonSeats()
        {
            var wagonsOfTrain = TrainBuilder.GetWagonsOfTrain(trainId).ToList();

            switch (_currentTabIndex)
            {
                case 0:
                    {
                        var currentBerthIndex = Berth.IndexOf(CurrentBerth);
                        Berth.Clear();
                        wagonsOfTrain.ForEach(wagon =>
                        {
                            var newWag = new WagonSeatsSet(wagon.Id, depDate, arrDate);
                            var wagonType = (WagonType)ContextKeeper.Wagons.Where(w => w.Id == wagon.Id).Select(w => w.WagonType.Value).First();
                            if (wagonType == WagonType.BERTH)
                            {
                                this.Berth.Add(newWag);
                            }
                        });
                        CurrentBerth = Berth[currentBerthIndex];
                        SetWagonSeatsButtonsVisibility(CurrentBerth, _berthSeatsVisibility);
                        BerthSeatsVisibility.Add(null);
                        break;
                    }
                case 1:
                    {
                        var currentCoupeIndex = Coupe.IndexOf(CurrentCoupe);
                        Coupe.Clear();
                        wagonsOfTrain.ForEach(wagon =>
                        {
                            var newWag = new WagonSeatsSet(wagon.Id, depDate, arrDate);
                            var wagonType = (WagonType)ContextKeeper.Wagons.Where(w => w.Id == wagon.Id).Select(w => w.WagonType.Value).First();
                            if (wagonType == WagonType.COUPE)
                            {
                                this.Coupe.Add(newWag);
                            }
                        });
                        CurrentCoupe = Coupe[currentCoupeIndex];
                        SetWagonSeatsButtonsVisibility(CurrentCoupe, _coupeSeatsVisibility);
                        CoupeSeatsVisibility.Add(null);
                        break;
                    }
                case 2:
                    {
                        var currentLuxIndex = Lux.IndexOf(CurrentLux);
                        Lux.Clear();
                        wagonsOfTrain.ForEach(wagon =>
                        {
                            var newWag = new WagonSeatsSet(wagon.Id, depDate, arrDate);
                            var wagonType = (WagonType)ContextKeeper.Wagons.Where(w => w.Id == wagon.Id).Select(w => w.WagonType.Value).First();
                            if (wagonType == WagonType.LUX)
                            {
                                this.Lux.Add(newWag);
                            }
                        });
                        CurrentLux = Lux[currentLuxIndex];
                        SetWagonSeatsButtonsVisibility(CurrentLux, _luxSeatsVisibility);
                        LuxSeatsVisibility.Add(null);
                        break;
                    }
            }
            ResetSelectedButton();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Формирование списков вагонов поезда по их типам
        /// </summary>
        /// <param name="trainId"></param>
        private async void SetTrainInfo()
        {
            await Task.Run(() => 
            {
                this.trainId = this._tripInfo.TrainId; ;
                this.depDate = this._tripInfo.DepartureTime;
                this.arrDate = this._tripInfo.ArrivalTime;

                Berth.Clear();
                Coupe.Clear();
                Lux.Clear();

                var wagonsOfTrain = TrainBuilder.GetWagonsOfTrain(trainId).ToList();
                wagonsOfTrain.ForEach(wagon =>
                {
                    var newWag = new WagonSeatsSet(wagon.Id, depDate, arrDate);
                    if (newWag.Seats.Any(freeSeat => freeSeat == true))
                    {
                        var wagonType = (WagonType)ContextKeeper.Wagons.Where(w => w.Id == wagon.Id).Select(w => w.WagonType.Value).First();
                        switch (wagonType)
                        {
                            case WagonType.BERTH:
                                {
                                    this.Berth.Add(newWag);
                                    break;
                                }
                            case WagonType.COUPE:
                                {
                                    this.Coupe.Add(newWag);
                                    break;
                                }
                            case WagonType.LUX:
                                {
                                    this.Lux.Add(newWag);
                                    break;
                                }
                        }
                    }
                });

                SetCurrentWagons();
                SetCurrentTab();
                NextEnabled = true;
                SetCurrentWagonInfo();
            });
           
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Установка видимости для кнопок, сответствующим местам в вагоне
        /// Видимая - если место занято,
        /// </summary>
        /// <param name="seats"></param>
        /// <param name="visibility"></param>
        private void SetWagonSeatsButtonsVisibility(WagonSeatsSet seats, ObservableRangeCollection<String> visibility)
        {
            visibility.Clear();

            visibility.AddRange(seats.Seats.Select(seatIsFree => 
            {
                return seatIsFree ? freeSeatOpacity : occupiedSeatOpacity;
            }));
        }
Ejemplo n.º 4
0
        public SeatSetViewModel()
        {
            _berth = new List<WagonSeatsSet>();
            _coupe = new List<WagonSeatsSet>();
            _lux = new List<WagonSeatsSet>();

            CurrentBerth = new WagonSeatsSet();
            CurrentCoupe = new WagonSeatsSet();
            CurrentLux = new WagonSeatsSet();

            _berthSeatsVisibility = new ObservableRangeCollection<String>();
            _coupeSeatsVisibility = new ObservableRangeCollection<String>();
            _luxSeatsVisibility = new ObservableRangeCollection<String>();

            SelectSeatCmd = new RelayCommand<object>(this.SelectSeat);
            NextWagonCmd = new RelayCommand(() => NextWagon());
            PrevWagonCmd = new RelayCommand(() => PrevWagon());
            ClientInfoInputCmd = new RelayCommand(() => ClientInfoInput());

            Messenger.Default.Register<TripInfoMessage>(this, (msg) =>
            {
                this._tripInfo = msg.CurrentTripInfo;
                SetTrainInfo();
                SetCurrentTripInfo();
            });
        }