Exemple #1
0
        static void Main(string[] args)
        {
            var car = new Car("Лада", "D");
            car.Color = Color.Purple;

            try
            {
                Console.WriteLine("Владелец - " + car.CarPassport.Owner.Name);
            }
            catch (Exception)
            {
                Console.WriteLine("Имя владельца лады не задано!");
            }

            var driver = new Driver("23.11.2015", "Вольдемар");
            driver.Category = "BC";

            try
            {
                car.ChangeOnwer("o777oo", driver);
            }
            catch (Exception)
            {

                Console.WriteLine("Ошибка!");
            }

            driver.Category += "D";
            car.ChangeOnwer("o777oo", driver);

            Console.WriteLine("Владелец машины: " + driver.Name);
            Console.WriteLine("Номер машины: " + car.CarNumber);

            Console.ReadKey();
        }
        public async Task<int> AddAsync(Driver driver)
        {
            _context.Drivers.Add(driver);

            await _context.SaveChangesAsync();

            return driver.DriverId;
        }
Exemple #3
0
        public void ChangeOwner(Driver driver, string carnumber)
        {
            driver.OwnCar(this);

            CarPassport.Owner = driver;
            CarNumber = carnumber;
            
        }
        public void ChangeOwner(string number, Driver driver)
        {
            Console.WriteLine("Закрепить за водителем имеющуюся машину:");

            driver.OwnCar(this);

            this.CarPass.Owner = driver;
            CarNumber = number;
        }
Exemple #5
0
 public void ChangeOwners(Driver driver, string carNumber)
 {
     driver.OwnCar(this);
     if (driver.Category.Contains(Category.ToString()))
     {
         CarPassport.Owner = driver;
         CarNumber = carNumber;
     }
 }
Exemple #6
0
        public void ChangeOwner(Driver driver, string newnumber)
        {
            if (driver.Category.Contains(Categor))
             {
                CarPassport.Owner = driver;
                driver.OwnCar(this);
                CarNumber = newnumber;
             }

             else
             {
                throw new NoCategoryException($"Водитель {driver.Name} не имеет нужной категории {Categor}");
            }
        }
Exemple #7
0
        static void Main(string[] args)
        {
            var model = "Лада";
            var category = 'D';
            var car = new Car(category, model) {Color = Color.DarkOrchid};

            try
            {
                Console.WriteLine("Имя владельца {0}: {1}", car.Model, car.CarPassport.Owner.Name);
            }
            catch (NullReferenceException exeption)
            {
                Console.WriteLine("Владельца {0} не существует! Сообщение об ошибке: {1}", car.Model, exeption.Message);
            }

            var Name = "Вольдемар";
            var Category = "BC";
            var driver = new Driver(new DateTime(2014, 07, 29), Name) { Category = Category };

            var CarNumber = "o777oo";
            try
            {
                car.ChangeOwner(driver, CarNumber);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }

            driver.Category = driver.Category + "D";
            try
            {
                car.ChangeOwner(driver, CarNumber);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }

            Console.WriteLine(driver.Car.CarNumber);
            Console.WriteLine(driver.Name);
            Console.ReadKey();
        }
Exemple #8
0
        private static void Main(string[] args)
        {
            Car car1 = new Car("Lada Sedan", 'D');
            car1.Color=Color.FromArgb(35, 3, 43);
            try
            {
                Console.WriteLine("Driver's name is"+ car1.CarPassport.Owner.Name);
            }
            catch (NullReferenceException)
            {
                Console.WriteLine("Impossible to show driver's name. " +
                                        "It hasn't been specified yet"); }

            var driver1 = new Driver(new DateTime(2007, 1, 11), "Voldemar");
            driver1.Category = "BC";
            try
            {
                car1.ChangeOwner(driver1, "o777oo");
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
            }

            driver1.Category = driver1.Category.Insert(2, "D");
            try
            {
                car1.ChangeOwner(driver1, "o777oo");
            }
            catch (CategoryOfDriverException)
            {

                Console.WriteLine("Driver has no needed category to rule this car.");
            }

            Console.WriteLine("Car number: "+ driver1.Car.CarNumber);
            Console.WriteLine("Owner's name: " + car1.CarPassport.Owner.Name);
            Console.WriteLine("Driver has experience of {0} years", driver1.Experience);

            Console.ReadKey();
        }
        private static void CreateVehicleAndDriver_15(int carrierId, MyShuttleContext context)
        {
            var driver = new Driver
            {
                Name = "Austin Lumbert",
                Phone = "555-48970",
                Picture = GetNoMsDriver(5),
                CarrierId = carrierId,
                RatingAvg = 2,
                TotalRides = Randomize.Next(50, 100),
            };
            context.Drivers.Add(driver);
            context.SaveChanges();

            var vehicle = new Vehicle
            {
                LicensePlate = "OUJ-6182",
                Model = "G5",
                Make = "Pontiac",
                Type = VehicleType.Luxury,
                Seats = 7,
                VehicleStatus = VehicleStatus.Occupied,
                DriverId = driver.DriverId,
                Picture = GetVehicle(15),
                Latitude = 47.641950,
                Longitude = -122.167222,
                CarrierId = carrierId,
                Rate = Randomize.Next(1, 5),
                RatingAvg = Randomize.Next(0, 5),
                TotalRides = Randomize.Next(50, 100),
                DeviceId = string.Empty
            };

            context.Vehicles.Add(vehicle);
            context.SaveChanges();
        }
        private static void CreateVehicleAndDriver_13(int carrierId, MyShuttleContext context)
        {
            var driver = new Driver
            {
                Name = "Aaron McDonall",
                Phone = "555-48970",
                Picture = GetNoMsDriver(3),
                CarrierId = carrierId,
                RatingAvg = 2,
                TotalRides = Randomize.Next(50, 100),
            };
            context.Drivers.Add(driver);
            context.SaveChanges();

            var vehicle = new Vehicle
            {
                LicensePlate = "HUL-5678",
                Model = "Aura XR",
                Make = "Saturn",
                Type = VehicleType.Luxury,
                Seats = 7,
                VehicleStatus = VehicleStatus.Occupied,
                DriverId = driver.DriverId,
                Picture = GetVehicle(13),
                Latitude = 47.644944,
                Longitude = -122.125222,
                CarrierId = carrierId,
                Rate = Randomize.Next(1, 5),
                RatingAvg = Randomize.Next(0, 5),
                TotalRides = Randomize.Next(50, 100),
                DeviceId = "deviceVehicleRC"
            };

            context.Vehicles.Add(vehicle);
            context.SaveChanges();
        }
        private static void CreateVehicleAndDriver_11(int carrierId, MyShuttleContext context)
        {
            var driver = new Driver
            {
                Name = "James Rodriguez",
                Phone = "555-48970",
                Picture = GetNoMsDriver(1),
                CarrierId = carrierId,
                RatingAvg = 2,
                TotalRides = Randomize.Next(50, 100),
            };
            context.Drivers.Add(driver);
            context.SaveChanges();

            var vehicle = new Vehicle
            {
                LicensePlate = "WWW-1256",
                Model = "Dart",
                Make = "Dodge",
                Type = VehicleType.Luxury,
                Seats = 7,
                VehicleStatus = VehicleStatus.Occupied,
                DriverId = driver.DriverId,
                Picture = GetVehicle(11),
                Latitude = 47.642944,
                Longitude = -122.128222,
                CarrierId = carrierId,
                Rate = Randomize.Next(1, 5),
                RatingAvg = Randomize.Next(0, 5),
                TotalRides = Randomize.Next(50, 100),
                DeviceId = "deviceVehicleSIM"
            };

            context.Vehicles.Add(vehicle);
            context.SaveChanges();
        }
        private static void CreateVehicleAndDriver_10(int carrierId, MyShuttleContext context)
        {
            var driver = new Driver
            {
                Name = "Scott Guthrie",
                Phone = "555-48970",
                Picture = GetDriver(10),
                CarrierId = carrierId,
                RatingAvg = 5,
                TotalRides = Randomize.Next(50, 100),
            };
            context.Drivers.Add(driver);
            context.SaveChanges();

            var vehicle = new Vehicle
            {
                LicensePlate = "ERT-1256",
                Model = "Caliber",
                Make = "Dodge",
                Type = VehicleType.Van,
                Seats = 7,
                VehicleStatus = VehicleStatus.Occupied,
                DriverId = driver.DriverId,
                Picture = GetVehicle(10),
                Latitude = 48.641924,
                Longitude = -122.127212,
                CarrierId = carrierId,
                Rate = Randomize.Next(1, 5),
                RatingAvg = Randomize.Next(0, 5),
                TotalRides = Randomize.Next(50, 100),
                DeviceId = "ERT-1256",
            };

            context.Vehicles.Add(vehicle);
            context.SaveChanges();
        }
        private static void CreateVehicleAndDriver_19(int carrierId, MyShuttleContext context)
        {
            var driver = new Driver
            {
                Name = "Carlos Rodriguez",
                Phone = "555-48970",
                Picture = GetNoMsDriver(9),
                CarrierId = carrierId,
                RatingAvg = 2,
                TotalRides = Randomize.Next(50, 100),
            };
            context.Drivers.Add(driver);
            context.SaveChanges();

            var vehicle = new Vehicle
            {
                LicensePlate = "ERT-2345",
                Model = "Impala LTZ",
                Make = "Chevrolet",
                Type = VehicleType.Luxury,
                Seats = 7,
                VehicleStatus = VehicleStatus.Occupied,
                DriverId = driver.DriverId,
                Picture = GetVehicle(19),
                Latitude = 47.641944,
                Longitude = -122.197232,
                CarrierId = carrierId,
                Rate = Randomize.Next(1, 5),
                RatingAvg = Randomize.Next(0, 5),
                TotalRides = Randomize.Next(50, 100),
                DeviceId = string.Empty
            };

            context.Vehicles.Add(vehicle);
            context.SaveChanges();
        }
        private Driver BuildDriver(Driver driver, Vehicle vehicle, bool includePicture = true)
        {
            //the idea is remove reference for improve
            //client work without $ref
            var created = new Driver
            {
                DriverId = driver.DriverId,
                CarrierId = driver.CarrierId,
                Name = driver.Name,
                Phone = driver.Phone,
                Picture = includePicture ? driver.Picture : null,
                VehicleId = driver.VehicleId,
                RatingAvg = driver.RatingAvg,
                TotalRides = driver.TotalRides,
                Vehicle = vehicle == null ? null :  new Vehicle()
                            {
                                LicensePlate = vehicle.LicensePlate,
                                Make = vehicle.Make,
                                Model = vehicle.Model
                            }
            };

            return created;
        }
        public async Task UpdateAsync(Driver driver)
        {
            _context.Drivers.Update(driver);

            await _context.SaveChangesAsync();
        }
        private static void CreateVehicleAndDriver_05(int carrierId, MyShuttleContext context)
        {
            var driver = new Driver
            {
                Name = "Scott Hanselman",
                Phone = "555-48970",
                Picture = GetDriver(5),
                CarrierId = carrierId,
                RatingAvg = 4.8,
                TotalRides = Randomize.Next(50, 100),
            };
            context.Drivers.Add(driver);
            context.SaveChanges();

            var vehicle = new Vehicle
            {
                LicensePlate = "FGH-9876",
                Model = "Volt2",
                Make = "Chevrolet",
                Type = VehicleType.Van,
                Seats = 7,
                VehicleStatus = VehicleStatus.Free,
                DriverId = driver.DriverId,
                Picture = GetVehicle(5),
                Latitude = 47.631925,
                Longitude = -122.127220,
                CarrierId = carrierId,
                Rate = Randomize.Next(1, 5),
                RatingAvg = Randomize.Next(0, 5),
                TotalRides = Randomize.Next(50, 100),
                DeviceId = "FGH-9876"
            };

            context.Vehicles.Add(vehicle);
            context.SaveChanges();
        }
        private static void CreateVehicleAndDriver_04(int carrierId, MyShuttleContext context)
        {
            var driver = new Driver
            {
                Name = "Dmitry Lyalin",
                Phone = "555-48970",
                Picture = GetDriver(4),
                CarrierId = carrierId,
                RatingAvg = Randomize.Next(0, 4),
                TotalRides = Randomize.Next(50, 100),
            };
            context.Drivers.Add(driver);
            context.SaveChanges();

            var vehicle = new Vehicle
            {
                LicensePlate = "JNV-9876",
                Model = "300C",
                Make = "Chrysler",
                Type = VehicleType.Van,
                Seats = 7,
                VehicleStatus = VehicleStatus.Occupied,
                DriverId = driver.DriverId,
                Picture = GetVehicle(4),
                Latitude = 47.841914,
                Longitude = -122.127222,
                CarrierId = carrierId,
                Rate = Randomize.Next(1, 5),
                RatingAvg = Randomize.Next(0, 5),
                TotalRides = Randomize.Next(50, 100),
                DeviceId = "JNV-9876"
            };

            context.Vehicles.Add(vehicle);
            context.SaveChanges();
        }
        private static void CreateVehicleAndDriver_03(int carrierId, MyShuttleContext context)
        {
            var driver = new Driver
            {
                Name = "David Salgado",
                Phone = "555-48970",
                Picture = GetDriver(3),
                CarrierId = carrierId,
                RatingAvg = 3,
                TotalRides = Randomize.Next(50, 100),
            };
            context.Drivers.Add(driver);
            context.SaveChanges();

            var vehicle = new Vehicle
            {
                LicensePlate = "ZCC-1432",
                Model = "Taurus",
                Make = "Ford",
                Type = VehicleType.Van,
                Seats = 7,
                VehicleStatus = VehicleStatus.Occupied,
                DriverId = driver.DriverId,
                Picture = GetVehicle(3),
                Latitude = 47.741924,
                Longitude = 122.127222,
                CarrierId = carrierId,
                Rate = Randomize.Next(1, 5),
                RatingAvg = Randomize.Next(0, 5),
                TotalRides = Randomize.Next(50, 100),
                DeviceId = "CCC-1432"
            };

            context.Vehicles.Add(vehicle);
            context.SaveChanges();
        }
        private static void CreateVehicleAndDriver_02(int carrierId, MyShuttleContext context)
        {
            var driver = new Driver
            {
                Name = "David Carmona",
                Phone = "555-48970",
                Picture = GetDriver(2),
                CarrierId = carrierId,
                RatingAvg = 4.6,
                TotalRides = Randomize.Next(50, 100),
            };
            context.Drivers.Add(driver);
            context.SaveChanges();

            var vehicle = new Vehicle
            {
                LicensePlate = "MAX-9876",
                Model = "Town Car",
                Make = "Lincoln",
                Type = VehicleType.Van,
                Seats = 7,
                VehicleStatus = VehicleStatus.Free,
                DriverId = driver.DriverId,
                Picture = GetVehicle(2),
                Latitude = 47.621934,
                Longitude = 122.127222,
                CarrierId = carrierId,
                Rate = Randomize.Next(1, 5),
                RatingAvg = Randomize.Next(0, 5),
                TotalRides = Randomize.Next(50, 100),
                DeviceId = "MAX-9876"
            };

            context.Vehicles.Add(vehicle);
            context.SaveChanges();
        }
        private static void CreateVehicleAndDriver_01(int carrierId, MyShuttleContext context)
        {
            var driver = new Driver
            {
                Name = "Cesar de la Torre",
                Phone = "555-178895",
                Picture = GetDriver(1),
                CarrierId = carrierId,
                RatingAvg = 4.5,
                TotalRides = Randomize.Next(50, 100),
            };
            context.Drivers.Add(driver);
            context.SaveChanges();

            var vehicle = new Vehicle
            {
                LicensePlate = "SLV-4335",
                Model = "Pacifica",
                Make = "Chrysler",
                Type = VehicleType.Compact,
                Seats = 4,
                VehicleStatus = VehicleStatus.Occupied,
                DriverId = driver.DriverId,
                CarrierId = carrierId,
                Picture = GetVehicle(1),
                Latitude = 47.621931,
                Longitude = -122.127232,
                Rate = Randomize.Next(1, 5),
                RatingAvg = Randomize.Next(0, 5),
                TotalRides = Randomize.Next(50, 100),
                DeviceId = "SLV-4335",
            };

            context.Vehicles.Add(vehicle);
            context.SaveChanges();
        }
        private static void CreateVehicleAndDriver_21(int carrierId, MyShuttleContext context)
        {
            var driver = new Driver
            {
                Name = "Andry Jackson",
                Phone = "555-48970",
                Picture = GetNoMsDriver(11),
                CarrierId = carrierId,
                RatingAvg = 2,
                TotalRides = Randomize.Next(50, 100),
            };
            context.Drivers.Add(driver);
            context.SaveChanges();

            var vehicle = new Vehicle
            {
                LicensePlate = "WIE-4545",
                Model = "Grand Prix",
                Make = "Pontiac",
                Type = VehicleType.Luxury,
                Seats = 7,
                VehicleStatus = VehicleStatus.Occupied,
                DriverId = driver.DriverId,
                Picture = GetVehicle(21),
                Latitude = 47.641944,
                Longitude = -122.327252,
                CarrierId = carrierId,
                Rate = Randomize.Next(1, 5),
                RatingAvg = Randomize.Next(0, 5),
                TotalRides = Randomize.Next(50, 100),
                DeviceId = string.Empty
            };

            context.Vehicles.Add(vehicle);
            context.SaveChanges();
        }
        private static void CreateVehicleAndDriver_16(int carrierId, MyShuttleContext context)
        {
            var driver = new Driver
            {
                Name = "Wendy Torre",
                Phone = "555-48970",
                Picture = GetNoMsDriver(14),
                CarrierId = carrierId,
                RatingAvg = 2,
                TotalRides = Randomize.Next(50, 100),
            };
            context.Drivers.Add(driver);
            context.SaveChanges();

            var vehicle = new Vehicle
            {
                LicensePlate = "ERT-1289",
                Model = "Regal",
                Make = "Buick",
                Type = VehicleType.Luxury,
                Seats = 7,
                VehicleStatus = VehicleStatus.Occupied,
                DriverId = driver.DriverId,
                Picture = GetVehicle(16),
                Latitude = 47.641951,
                Longitude = -122.177222,
                CarrierId = carrierId,
                Rate = Randomize.Next(1, 5),
                RatingAvg = Randomize.Next(0, 5),
                TotalRides = Randomize.Next(50, 100),
                DeviceId = string.Empty
            };

            context.Vehicles.Add(vehicle);
            context.SaveChanges();
        }
        private static void CreateVehicleAndDriver_14(int carrierId, MyShuttleContext context)
        {
            var driver = new Driver
            {
                Name = "Alan Anderson",
                Phone = "555-48970",
                Picture = GetNoMsDriver(4),
                CarrierId = carrierId,
                RatingAvg = 2,
                TotalRides = Randomize.Next(50, 100),
            };
            context.Drivers.Add(driver);
            context.SaveChanges();

            var vehicle = new Vehicle
            {
                LicensePlate = "WTW-6182",
                Model = "G6",
                Make = "Pontiac",
                Type = VehicleType.Luxury,
                Seats = 7,
                VehicleStatus = VehicleStatus.Occupied,
                DriverId = driver.DriverId,
                Picture = GetVehicle(14),
                Latitude = 41.151172,
                Longitude = -87.914014,
                CarrierId = carrierId,
                Rate = Randomize.Next(1, 5),
                RatingAvg = Randomize.Next(0, 5),
                TotalRides = Randomize.Next(50, 100),
                DeviceId = string.Empty
            };

            context.Vehicles.Add(vehicle);
            context.SaveChanges();
        }
        private static void CreateVehicleAndDriver_05(int carrierId, MyShuttleContext context)
        {
            var driver = new Driver
            {
                Name = "Jay Schmelzer",
                Phone = "555-1212",
                Picture = GetDriver(6),
                CarrierId = carrierId,
                RatingAvg = 5,
                TotalRides = Randomize.Next(80, 90),
            };
            context.Drivers.Add(driver);
            context.SaveChanges();

            var vehicle = new Vehicle
            {
                LicensePlate = "ZUA-1456",
                Model = "Caprice PPV",
                Make = "Chevrolet",
                Type = VehicleType.Van,
                Seats = 7,
                VehicleStatus = VehicleStatus.Free,
                DriverId = driver.DriverId,
                Picture = GetVehicle(6),
                Latitude = 41.721172,
                Longitude = -87.604014,
                CarrierId = carrierId,
                Rate = Randomize.Next(1, 5),
                RatingAvg = Randomize.Next(0, 5),
                TotalRides = Randomize.Next(50, 100),
                DeviceId = "CUA-1456",
            };

            context.Vehicles.Add(vehicle);
            context.SaveChanges();
        }
        private static void CreateVehicleAndDriver_08(int carrierId, MyShuttleContext context)
        {
            var driver = new Driver
            {
                Name = "Rob Caron",
                Phone = "555-48970",
                Picture = GetDriver(8),
                CarrierId = carrierId,
                RatingAvg = Randomize.Next(0, 3),
                TotalRides = Randomize.Next(50, 100),
            };
            context.Drivers.Add(driver);
            context.SaveChanges();

            var vehicle = new Vehicle
            {
                LicensePlate = "HTY-1243",
                Model = "ELR",
                Make = "Cadilac",
                Type = VehicleType.Van,
                Seats = 7,
                VehicleStatus = VehicleStatus.Occupied,
                DriverId = driver.DriverId,
                Picture = GetVehicle(8),
                Latitude = 47.621954,
                Longitude = -122.127212,
                CarrierId = carrierId,
                Rate = Randomize.Next(1, 5),
                RatingAvg = Randomize.Next(0, 5),
                TotalRides = Randomize.Next(50, 100),
                DeviceId = "HTY-1243",
            };

            context.Vehicles.Add(vehicle);
            context.SaveChanges();
        }
        private static void CreateVehicleAndDriver_09(int carrierId, MyShuttleContext context)
        {
            var driver = new Driver
            {
                Name = "S. Somasegar",
                Phone = "555-48970",
                Picture = GetDriver(9),
                CarrierId = carrierId,
                RatingAvg = Randomize.Next(0, 3),
                TotalRides = Randomize.Next(50, 100),
            };
            context.Drivers.Add(driver);
            context.SaveChanges();

            var vehicle = new Vehicle
            {
                LicensePlate = "VVV-4444",
                Model = "AveoLT",
                Make = "Chevrolet",
                Type = VehicleType.Van,
                Seats = 7,
                VehicleStatus = VehicleStatus.Free,
                DriverId = driver.DriverId,
                Picture = GetVehicle(9),
                Latitude = 47.641964,
                Longitude = -122.127212,
                CarrierId = carrierId,
                Rate = Randomize.Next(1, 5),
                RatingAvg = Randomize.Next(0, 5),
                TotalRides = Randomize.Next(50, 100),
                DeviceId = "VVV-4444",
            };

            context.Vehicles.Add(vehicle);
            context.SaveChanges();
        }
        private static void CreateVehicleAndDriver_06(int carrierId, MyShuttleContext context)
        {
            var driver = new Driver
            {
                Name = "Erich Gamma",
                Phone = "555-48970",
                Picture = GetDriver(6),
                CarrierId = carrierId,
                RatingAvg = Randomize.Next(0, 3),
                TotalRides = Randomize.Next(50, 100),
            };
            context.Drivers.Add(driver);
            context.SaveChanges();

            var vehicle = new Vehicle
            {
                LicensePlate = "ZUA-1456",
                Model = "Caprice PPV",
                Make = "Chevrolet",
                Type = VehicleType.Van,
                Seats = 7,
                VehicleStatus = VehicleStatus.Free,
                DriverId = driver.DriverId,
                Picture = GetVehicle(6),
                Latitude = 47.631935,
                Longitude = -122.127222,
                CarrierId = carrierId,
                Rate = Randomize.Next(1, 5),
                RatingAvg = Randomize.Next(0, 5),
                TotalRides = Randomize.Next(50, 100),
                DeviceId = "CUA-1456",
            };

            context.Vehicles.Add(vehicle);
            context.SaveChanges();
        }
        private static void CreateVehicleAndDriver_18(int carrierId, MyShuttleContext context)
        {
            var driver = new Driver
            {
                Name = "Ibon Campa",
                Phone = "555-48970",
                Picture = GetNoMsDriver(10),
                CarrierId = carrierId,
                RatingAvg = 2,
                TotalRides = Randomize.Next(50, 100),
            };
            context.Drivers.Add(driver);
            context.SaveChanges();

            var vehicle = new Vehicle
            {
                LicensePlate = "RTY-2345",
                Model = "Riviera",
                Make = "Buick",
                Type = VehicleType.Luxury,
                Seats = 7,
                VehicleStatus = VehicleStatus.Occupied,
                DriverId = driver.DriverId,
                Picture = GetVehicle(18),
                Latitude = 47.641944,
                Longitude = -122.187212,
                CarrierId = carrierId,
                Rate = Randomize.Next(1, 5),
                RatingAvg = Randomize.Next(0, 5),
                TotalRides = Randomize.Next(50, 100),
                DeviceId = "deviceVehicleLED"
            };

            context.Vehicles.Add(vehicle);
            context.SaveChanges();
        }
        private Vehicle BuildVehicle(Vehicle vehicle, Driver driver, Carrier carrier, double distanceFromGivenPosition = 0, 
            bool includePicture = true)
        {
            //the idea is remove reference for improve 
            //client work without $ref
            var created = new Vehicle
            {
                VehicleId = vehicle.VehicleId,
                CarrierId = vehicle.CarrierId,
                Picture = includePicture ? vehicle.Picture : null,
                DriverId = vehicle.DriverId,
                LicensePlate = vehicle.LicensePlate,
                DistanceFromGivenPosition = distanceFromGivenPosition,
                Make = vehicle.Make,
                Latitude = vehicle.Latitude,
                Longitude = vehicle.Longitude,
                Model = vehicle.Model,
                Seats = vehicle.Seats,
                Type = vehicle.Type,
                VehicleStatus = vehicle.VehicleStatus,
                Rate = vehicle.Rate,
                RatingAvg = vehicle.RatingAvg,
                TotalRides = vehicle.TotalRides,
                DeviceId = vehicle.DeviceId,
                Driver = driver == null ? null : new Driver()
                {
                    DriverId = driver.DriverId,
                    Name = driver.Name,
                    Phone = driver.Phone
                },
                Carrier = carrier == null ? null : new Carrier()
                {
                    Picture = carrier.Picture
                },
            };

            return created;
        }
        private static void CreateVehicleAndDriver_07(int carrierId, MyShuttleContext context)
        {
            var driver = new Driver
            {
                Name = "Mitra Azizirad",
                Phone = "555-48970",
                Picture = GetDriver(7),
                CarrierId = carrierId,
                RatingAvg = 4.6,
                TotalRides = Randomize.Next(50, 100),
            };
            context.Drivers.Add(driver);
            context.SaveChanges();

            var vehicle = new Vehicle
            {
                LicensePlate = "JOP-9876",
                Model = "BLS",
                Make = "Cadillac",
                Type = VehicleType.Van,
                Seats = 7,
                VehicleStatus = VehicleStatus.Occupied,
                DriverId = driver.DriverId,
                Picture = GetVehicle(7),
                Latitude = 47.631915,
                Longitude = -122.127221,
                CarrierId = carrierId,
                Rate = Randomize.Next(1, 5),
                RatingAvg = Randomize.Next(0, 5),
                TotalRides = Randomize.Next(50, 100),
                DeviceId = "JOP-9876",
            };

            context.Vehicles.Add(vehicle);
            context.SaveChanges();
        }