示例#1
0
文件: Server.cs 项目: Kant8/Railway
        public static List<Station> GetJunktionStationPairs(Station station)
        {
            var junkStations = GetJunktionStations().Except(new[] {station});

            var segments = GetStationsOnSegmentsByStationId(station.Id);

            var res = new List<Station>();
            foreach (var segment in segments)
            {
                var ws = segment.Where(seg =>
                {
                    var js = junkStations.FirstOrDefault(st => st.Id == seg.StationId);
                    return js != null;
                });
                res.AddRange(ws.Select(w => junkStations.First(js => js.Id == w.StationId)));
            }
            return res;
        }
示例#2
0
文件: Server.cs 项目: Kant8/Railway
        private Train CreateTrain(Station startStation)
        {
            var driver = new Worker
            {
                FirstName = "Андрей",
                MiddleName = "Андрей",
                LastName = "Андрей",
                Salary = 400m,
                LengthOfService = 1
            };

            var cond1 = new Worker
            {
                FirstName = "cond1",
                MiddleName = "cond1",
                LastName = "cond1",
                Salary = 200,
                LengthOfService = 1
            };
            var cond2 = new Worker
            {
                FirstName = "cond2",
                MiddleName = "cond2",
                LastName = "cond2",
                Salary = 200,
                LengthOfService = 1
            };
            var cond3 = new Worker
            {
                FirstName = "cond3",
                MiddleName = "cond3",
                LastName = "cond3",
                Salary = 200,
                LengthOfService = 1
            };

            var train = new Train
            {
                Name = "First Train",
                CurrentStation = startStation,
                Driver = driver,
                Velocity = 60
            };

            var wagon1 = new Wagon {MaxPassengerCount = 3, Conductor = cond1};
            var wagon2 = new Wagon { MaxPassengerCount = 3, Conductor = cond2 };
            var wagon3 = new Wagon { MaxPassengerCount = 3, Conductor = cond3 };

            train.Wagons.Add(wagon1); train.Wagons.Add(wagon2); train.Wagons.Add(wagon3);

            return train;
        }
示例#3
0
文件: MainForm.cs 项目: Kant8/Railway
        private void buttonAddStation_Click(object sender, EventArgs e)
        {
            var newStationName = textBoxNewStationName.Text;
            if (String.IsNullOrWhiteSpace(newStationName))
            {
                MessageBox.Show("Введите название станции");
                return;
            }

            var station = new Station {Name = newStationName};
            Server.Context.Stations.Add(station);
            Server.Context.SaveChanges();
            RefreshDataSources();
        }