public static void FillRoute(Route route) { var endTime = GetTimeTillStationOnRoute(route.Id, route.EndStationId); route.EndTime = endTime; }
private void buttonAddRoute_Click(object sender, EventArgs e) { var startStation = comboBoxJunkStationsStart.SelectedItem as Station; var endStation = comboBoxJunkStationsEnd.SelectedItem as Station; var strTime = textBoxRouteDepartureTime.Text; var train = comboBoxRouteTrains.SelectedItem as Train; if (startStation == null || endStation == null || train == null) return; DateTime startTime; try { startTime = Server.CreateTrainTime(strTime); } catch { MessageBox.Show("Формат времени ЧЧ:ММ"); return; } var route = new Route { StartStation = startStation, EndStation = endStation, StartTime = startTime, Train = train }; Server.Context.Routes.Add(route); Server.Context.SaveChanges(); Server.FillRoute(route); Server.Context.SaveChanges(); }