Example #1
0
        private void AddDeparture_Click(object sender, RoutedEventArgs e)
        {
            var addDepartureDialog = new AddDeparture();

            if (addDepartureDialog.ShowDialog() == true)
            {
                using (var context = new TimeTable())
                {
                    context.Add(addDepartureDialog.NewDeparture);
                    context.SaveChanges();
                }

                RefreshTables();
            }
        }
Example #2
0
        private void RemoveDeparture_Click(object sender, RoutedEventArgs e)
        {
            var removeDepartureDialog = new RemoveDeparture();

            if (removeDepartureDialog.ShowDialog() == true)
            {
                using (var context = new TimeTable())
                {
                    int id = removeDepartureDialog.DepartureId;

                    context.Remove(context.Departure.Single(x => x.Id == id));
                    context.SaveChanges();
                }

                RefreshTables();
            }
        }
Example #3
0
        private void AddCity_Click(object sender, RoutedEventArgs e)
        {
            var addCityDialog = new AddCity();

            if (addCityDialog.ShowDialog() == true)
            {
                using (var context = new TimeTable())
                {
                    context.Add(new City {
                        Id = null, Name = addCityDialog.NewName
                    });
                    context.SaveChanges();
                }

                RefreshTables();
            }
        }
Example #4
0
        public AddDeparture()
        {
            InitializeComponent();

            using (var context = new TimeTable())
            {
                var connections = context.Connection
                                  .Select(x => new { x.Id, start = x.Start.Name, destination = x.Destination.Name, train = x.Train.Name })
                                  .ToList();

                foreach (var connection in connections)
                {
                    var newComboItem = new ComboBoxItem
                    {
                        Content = $"{connection.start} => {connection.destination} : {connection.train}",
                        Tag     = connection.Id
                    };

                    Connection.Items.Add(newComboItem);
                }
            }
        }