Ejemplo n.º 1
0
        /// <summary>
        /// Processes a quote
        /// </summary>
        /// <param name="id">The ID of the quote to process</param>
        private void LoadExistingQuote(int id)
        {
            var db = new QuotesDBEntities();
            this.Quote = db.Quotes.Single(i => i.ID == id);

            this.ShowCustomerInformation();
            this.ShowPriceSummary();
        }
Ejemplo n.º 2
0
        private void CopyDrivers(Quote oldQuote, int newQuoteId)
        {
            var db = new QuotesDBEntities();

            var driverList = db.Drivers.Select(d => d).Where(d => d.QuoteID == oldQuote.ID);
            foreach (var oldDriver in driverList)
            {
                var newDriver = new Driver
                {
                    FirstName = oldDriver.FirstName,
                    LastName = oldDriver.LastName,
                    Ssn = oldDriver.Ssn,
                    DateOfBirth = oldDriver.DateOfBirth,
                    DriverLicenseNumber = oldDriver.DriverLicenseNumber,
                    DLState = oldDriver.DLState,
                    SafeDrivingSchool = oldDriver.SafeDrivingSchool,
                    QuoteID = newQuoteId
                };

                db.Drivers.AddObject(newDriver);
            }

            db.SaveChanges();
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Quotes EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToQuotes(Quote quote)
 {
     base.AddObject("Quotes", quote);
 }
 /// <summary>
 /// Create a new Quote object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="customerFirstName">Initial value of the CustomerFirstName property.</param>
 /// <param name="customerLastName">Initial value of the CustomerLastName property.</param>
 /// <param name="address">Initial value of the Address property.</param>
 /// <param name="city">Initial value of the City property.</param>
 /// <param name="stateId">Initial value of the StateId property.</param>
 /// <param name="zip">Initial value of the Zip property.</param>
 /// <param name="dateOfBirth">Initial value of the DateOfBirth property.</param>
 /// <param name="incomplete">Initial value of the Incomplete property.</param>
 /// <param name="claimsInPast5Yrs">Initial value of the ClaimsInPast5Yrs property.</param>
 /// <param name="hasMovingViolations">Initial value of the HasMovingViolations property.</param>
 /// <param name="hasLessThan3YrsDriving">Initial value of the HasLessThan3YrsDriving property.</param>
 /// <param name="forceMultiCarDiscount">Initial value of the ForceMultiCarDiscount property.</param>
 /// <param name="dateCreated">Initial value of the DateCreated property.</param>
 /// <param name="userId">Initial value of the UserId property.</param>
 public static Quote CreateQuote(global::System.Int32 id, global::System.String customerFirstName, global::System.String customerLastName, global::System.String address, global::System.String city, global::System.Int32 stateId, global::System.String zip, global::System.DateTime dateOfBirth, global::System.Boolean incomplete, global::System.Boolean claimsInPast5Yrs, global::System.Boolean hasMovingViolations, global::System.Boolean hasLessThan3YrsDriving, global::System.Boolean forceMultiCarDiscount, global::System.DateTime dateCreated, global::System.Guid userId)
 {
     Quote quote = new Quote();
     quote.ID = id;
     quote.CustomerFirstName = customerFirstName;
     quote.CustomerLastName = customerLastName;
     quote.Address = address;
     quote.City = city;
     quote.StateId = stateId;
     quote.Zip = zip;
     quote.DateOfBirth = dateOfBirth;
     quote.Incomplete = incomplete;
     quote.ClaimsInPast5Yrs = claimsInPast5Yrs;
     quote.HasMovingViolations = hasMovingViolations;
     quote.HasLessThan3YrsDriving = hasLessThan3YrsDriving;
     quote.ForceMultiCarDiscount = forceMultiCarDiscount;
     quote.DateCreated = dateCreated;
     quote.UserId = userId;
     return quote;
 }
Ejemplo n.º 5
0
 private int CopyQuoteInfo(Quote oldQuote)
 {
     var db = new QuotesDBEntities();
     var newQuote = new Quote
     {
         UserId = (Guid)Membership.GetUser(HttpContext.Current.User.Identity.Name).ProviderUserKey,
         CustomerFirstName = oldQuote.CustomerFirstName,
         CustomerLastName = oldQuote.CustomerLastName,
         Address = oldQuote.Address,
         City = oldQuote.City,
         StateId = oldQuote.StateId,
         Ssn = oldQuote.Ssn,
         Zip = oldQuote.Zip,
         DateOfBirth = oldQuote.DateOfBirth,
         DateCreated = DateTime.Now,
         Incomplete = true,
         ClaimsInPast5Yrs = oldQuote.ClaimsInPast5Yrs,
         ForceMultiCarDiscount = oldQuote.ForceMultiCarDiscount,
         HasLessThan3YrsDriving = oldQuote.HasLessThan3YrsDriving,
         HasMovingViolations = oldQuote.HasMovingViolations
     };
     db.Quotes.AddObject(newQuote);
     db.SaveChanges();
     return newQuote.ID;
 }
Ejemplo n.º 6
0
        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();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Loads a previously saved, incomplete quote
        /// </summary>
        /// <param name="id">The ID of the quote to load</param>
        private void LoadExistingQuote(int id)
        {
            if (CurrentQuote == null || CurrentQuote.ID != id)
            {
                var db = new QuotesDBEntities();
                this.CurrentQuote = db.Quotes.Single(i => i.ID == id);
                ucCustomerInfo.Read(CurrentQuote);
            }

            // TODO: Make sure the quote is incomplete, we don't want to load a completed quote

            CompleteCustomerInfo();
        }