Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.Write("Start date: ");
            DateTime startDateTime = DateTime.Parse(Console.ReadLine());
            Console.Write("End date: ");
            DateTime endDateTime = DateTime.Parse(Console.ReadLine());

            var stationRepo = new StationRepository();

            foreach (var station in stationRepo.GetStations(0, 100))
            {
                stationRepo.DeleteStation(station);
            }

            foreach (var station in stations)
            {
                Console.WriteLine("*****{0}*****", station);
                unavailabilityReasons = new UnavailabilityReasonRepository().GetUnavailabilityReasons(0, 100);

                Station s = new Station();
                s.Name = station;
                s.Postcode = "POST";
                s.Latitude = 100;
                s.Longitude = 100;
                s.StationID = Guid.NewGuid();
                s.CrewMembers = new List<CrewMember>();

                for (int i = 0; i < 10; i++)
                {
                    CrewMember cm = new CrewMember();
                    cm.CrewMemberID = Guid.NewGuid();
                    cm.FirstName = firstNames.ElementAt(rand.Next(0, firstNames.Count()));
                    cm.LastName = lastNames.ElementAt(rand.Next(0, lastNames.Count()));
                    cm.PersonalMobileNumber = "0001111";
                    cm.IsDriver = false;
                    cm.StationID = s.StationID;

                    CreateUavForCM(cm, startDateTime, endDateTime);
                    s.CrewMembers.Add(cm);
                    Console.WriteLine("CM {0} for {1}", i, station);
                }
                s.Appliances = new List<Appliance>();
                for (int i = 0; i < 5; i++)
                {
                    var app = new Appliance()
                    {
                        ApplianceID = Guid.NewGuid(),
                        MaximumCrewCapacity = 7,
                        MinimumCrewCount = 3,
                        Name = appliances.ElementAt(rand.Next(0, 4)) + " Truck",
                        StationID = s.StationID
                    };
                    s.Appliances.Add(app);
                }

                stationRepo.InsertStation(s);
            }
            stationRepo.SaveChanges();
        }
Exemplo n.º 2
0
 public void InsertStation(Station station)
 {
     _ctx.Stations.Add(station);
 }
Exemplo n.º 3
0
 public void DeleteStation(Station station)
 {
     _ctx.Stations.Remove(station);
 }