예제 #1
0
 /// <summary>
 /// Сохранение изменений информации о поезде
 /// </summary>
 /// <param name="window"></param>
 private void SaveTrainInfo(TrainInfoWindow window) 
 {
     if (String.IsNullOrEmpty(TrainNum)) return;
     if (_trainToEdit == null)
     {
         _trainToEdit = new Train();
         _trainToEdit.TrainNum = TrainNum;
         ContextKeeper.Trains.Add(_trainToEdit);
     }
     _trainToEdit.TrainNum = TrainNum;
     ContextKeeper.Trains.Update(_trainToEdit);
     window.Close();
 }
예제 #2
0
 /// <summary>
 /// Установка данных текущего поезда
 /// </summary>
 /// <param name="trainId"></param>
 public void SetWagonInfo(int trainId)
 {
     this._trainToEdit = ContextKeeper.Trains.First(train => train.Id == trainId);
     this.TrainNum = _trainToEdit.TrainNum;
     RefreshWagonsList();
 }
예제 #3
0
        /// <summary>
        /// Добавление вагона к поезду
        /// </summary>
        /// <returns></returns>
        public async Task AddWagon() 
        {
            if (_trainToEdit == null)
            {
                _trainToEdit = new Train();
                _trainToEdit.TrainNum = TrainNum;
                ContextKeeper.Trains.Add(_trainToEdit);
            }
            System.Console.WriteLine(SelectedWagonType);
            WagonType wType = (WagonType)int.Parse(SelectedWagonType);
            try
            {
                await TrainBuilder.AddWagonToTrain(_trainToEdit.Id, wType);
                RefreshWagonsList();
            }
            catch (Exception)
            {
                Console.WriteLine("Жди, пока добавится предыдущий");
            }

        }