/// <summary>
 /// Create a new Vehicle object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="vin">Initial value of the Vin property.</param>
 /// <param name="make">Initial value of the Make property.</param>
 /// <param name="model">Initial value of the Model property.</param>
 /// <param name="year">Initial value of the Year property.</param>
 /// <param name="primaryDriver">Initial value of the PrimaryDriver property.</param>
 /// <param name="antiTheft">Initial value of the AntiTheft property.</param>
 /// <param name="antiLock">Initial value of the AntiLock property.</param>
 /// <param name="daytimeRunningLights">Initial value of the DaytimeRunningLights property.</param>
 /// <param name="differentGarageAddress">Initial value of the DifferentGarageAddress property.</param>
 /// <param name="passiveRestraints">Initial value of the PassiveRestraints property.</param>
 /// <param name="reducedUsedDiscount">Initial value of the ReducedUsedDiscount property.</param>
 /// <param name="quoteId">Initial value of the QuoteId property.</param>
 public static Vehicle CreateVehicle(global::System.Int32 id, global::System.String vin, global::System.String make, global::System.String model, global::System.Int32 year, global::System.Int32 primaryDriver, global::System.Boolean antiTheft, global::System.Boolean antiLock, global::System.Boolean daytimeRunningLights, global::System.Boolean differentGarageAddress, global::System.Boolean passiveRestraints, global::System.Boolean reducedUsedDiscount, global::System.Int32 quoteId)
 {
     Vehicle vehicle = new Vehicle();
     vehicle.ID = id;
     vehicle.Vin = vin;
     vehicle.Make = make;
     vehicle.Model = model;
     vehicle.Year = year;
     vehicle.PrimaryDriver = primaryDriver;
     vehicle.AntiTheft = antiTheft;
     vehicle.AntiLock = antiLock;
     vehicle.DaytimeRunningLights = daytimeRunningLights;
     vehicle.DifferentGarageAddress = differentGarageAddress;
     vehicle.PassiveRestraints = passiveRestraints;
     vehicle.ReducedUsedDiscount = reducedUsedDiscount;
     vehicle.QuoteId = quoteId;
     return vehicle;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Vehicles EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToVehicles(Vehicle vehicle)
 {
     base.AddObject("Vehicles", vehicle);
 }
        private void CopyVehicles(Quote oldQuote, int newQuoteId)
        {
            var db = new QuotesDBEntities();
            var vehicleList = db.Vehicles.Select(d => d).Where(v => v.QuoteId == oldQuote.ID);

            foreach (var vehicle in vehicleList)
            {
                // TODO: Find a better way to copy the primary driver info than compare the driver license number

                // Find the driver's licence number of the primary driver of the original vehicle
                var a = db.Drivers.Single(d => d.ID == vehicle.PrimaryDriver).DriverLicenseNumber;

                // Find the ID of the driver in the new quote that has the same licence number as the original one
                var b = db.Quotes.Single(q => q.ID == newQuoteId).Drivers.Single(d => d.DriverLicenseNumber == a).ID;

                var newVehicle = new Vehicle
                    {
                        Vin = vehicle.Vin,
                        Make = vehicle.Make,
                        Model = vehicle.Model,
                        Year = vehicle.Year,
                        CurrentValue = vehicle.CurrentValue,
                        PrimaryDriver = b,
                        AnnualMileage = vehicle.AnnualMileage,
                        DaysDrivenPerWeek = vehicle.DaysDrivenPerWeek,
                        MilesDrivenToWork = vehicle.MilesDrivenToWork,
                        AntiTheft = vehicle.AntiTheft,
                        AntiLock = vehicle.AntiLock,
                        DaytimeRunningLights = vehicle.DaytimeRunningLights,
                        DifferentGarageAddress = vehicle.DifferentGarageAddress,
                        PassiveRestraints = vehicle.PassiveRestraints,
                        ReducedUsedDiscount = vehicle.ReducedUsedDiscount,
                        QuoteId = newQuoteId
                    };
                db.Vehicles.AddObject(newVehicle);
            }

            db.SaveChanges();
        }