Ejemplo n.º 1
0
        public void Run(Quote quote)
        {
            var db = new QuotesDBEntities();

            if (quote.ForceMultiCarDiscount)
            {
                var stateId              = quote.StateId;
                var discount             = db.DiscountPerStates.Single(d => d.DiscountId == discountId && d.StateId == stateId);
                var appliedDiscountValue = new QuoteDiscount()
                {
                    DiscountId           = this.discountId,
                    StateId              = stateId,
                    QuoteId              = quote.ID,
                    AppliedDiscountValue = discount.Amount
                };
                db.AddToQuoteDiscounts(appliedDiscountValue);
            }
            db.SaveChanges();
        }
        public void Run(Quote quote)
        {
            var db = new QuotesDBEntities();

            if (quote.HasMovingViolations)
            {
                var stateId = (int) db.Drivers.First().DLState;
                var discount = db.DiscountPerStates.Single(d => d.DiscountId == discountId && d.StateId == stateId);
                var appliedDiscountValue = new QuoteDiscount()
                    {
                        DiscountId = this.discountId,
                        StateId = stateId,
                        QuoteId = quote.ID,
                        AppliedDiscountValue = discount.Amount
                    };
                db.AddToQuoteDiscounts(appliedDiscountValue);
            }
            db.SaveChanges();
        }
Ejemplo n.º 3
0
        public void Run(Quote quote)
        {
            var db = new QuotesDBEntities();
            if (quote.ForceMultiCarDiscount)
            {

                var stateId = quote.StateId;
                var discount = db.DiscountPerStates.Single(d => d.DiscountId == discountId && d.StateId == stateId);
                var appliedDiscountValue = new QuoteDiscount()
                    {
                        DiscountId = this.discountId,
                        StateId = stateId,
                        QuoteId = quote.ID,
                        AppliedDiscountValue = discount.Amount
                    };
                db.AddToQuoteDiscounts(appliedDiscountValue);
            }
            db.SaveChanges();
        }
        public void Run(Quote quote)
        {
            var db = new QuotesDBEntities();
            if (quote.PreviousCarrier != null)
            if (quote.PreviousCarrier.ToLower().Contains("pervasive"))
            {

                var stateId = quote.StateId;
                var discount = db.DiscountPerStates.Single(d => d.DiscountId == discountId && d.StateId == stateId);
                var appliedDiscountValue = new QuoteDiscount()
                    {
                        DiscountId = this.discountId,
                        StateId = stateId,
                        QuoteId = quote.ID,
                        AppliedDiscountValue = discount.Amount
                    };
                db.AddToQuoteDiscounts(appliedDiscountValue);
            }
            db.SaveChanges();
        }
Ejemplo n.º 5
0
        public void Run(Web.Quote quote)
        {
            var db = new QuotesDBEntities();

            foreach (var driver in quote.Drivers)
            {
                if (driver.DateOfBirth.AddYears(23) > DateTime.Now)
                {
                    var discount             = db.DiscountPerStates.Single(d => d.DiscountId == discountId && d.StateId == driver.DLState);
                    var appliedDiscountValue = new DriverDiscount()
                    {
                        DiscountId           = this.discountId,
                        StateId              = driver.DLState,
                        DriverId             = driver.ID,
                        AppliedDiscountValue = discount.Amount
                    };
                    db.AddToDriverDiscounts(appliedDiscountValue);
                }
            }

            db.SaveChanges();
        }
Ejemplo n.º 6
0
        public void Run(Web.Quote quote)
        {
            var db = new QuotesDBEntities();

            foreach (var driver in quote.Drivers)
            {
                if (driver.SafeDrivingSchool)
                {
                    var discount        = db.DiscountPerStates.Single(d => d.DiscountId == discountId && d.StateId == driver.DLState);
                    var appliedDiscount = new DriverDiscount()
                    {
                        DriverId             = driver.ID,
                        StateId              = (int)driver.DLState,
                        DiscountId           = discount.DiscountId,
                        AppliedDiscountValue = discount.Amount
                    };
                    db.AddToDriverDiscounts(appliedDiscount);
                }
            }

            db.SaveChanges();
        }
Ejemplo n.º 7
0
        public void Run(Quote quote)
        {
            var db = new QuotesDBEntities();

            if (quote.PreviousCarrier != null)
            {
                if (quote.PreviousCarrier.ToLower().Contains("lizard"))
                {
                    var stateId              = quote.StateId;
                    var discount             = db.DiscountPerStates.Single(d => d.DiscountId == discountId && d.StateId == stateId);
                    var appliedDiscountValue = new QuoteDiscount()
                    {
                        DiscountId           = this.discountId,
                        StateId              = stateId,
                        QuoteId              = quote.ID,
                        AppliedDiscountValue = discount.Amount
                    };
                    db.AddToQuoteDiscounts(appliedDiscountValue);
                }
            }
            db.SaveChanges();
        }
Ejemplo n.º 8
0
        public void Run(Web.Quote quote)
        {
            var db = new QuotesDBEntities();

            foreach (var vehicle in quote.Vehicles)
            {
                if (vehicle.DaysDrivenPerWeek > 4)
                {
                    var stateId  = db.Drivers.Single(p => p.ID == vehicle.PrimaryDriver).DLState;
                    var discount =
                        db.DiscountPerStates.Single(d => d.DiscountId == this.discountId && d.StateId == stateId);
                    var appliedDiscountValue = new VehicleDiscount()
                    {
                        AppliedDiscountValue = discount.Amount,
                        DiscountId           = this.discountId,
                        StateId   = stateId,
                        VehicleId = vehicle.ID
                    };

                    db.AddToVehicleDiscounts(appliedDiscountValue);
                }
            }
            db.SaveChanges();
        }
        /// <summary>
        /// This function applies the rule to a given quote.
        /// </summary>
        /// <param name="quote">The quote object that the rule should be applied to</param>
        public void Run(Quote quote)
        {
            var db = new QuotesDBEntities();

            foreach (var vehicle in quote.Vehicles)
            {
                if (vehicle.ReducedUsedDiscount)
                {
                    var vehicleOwner = db.Drivers.Single(p => p.ID == vehicle.PrimaryDriver);
                    var discount = db.DiscountPerStates.Single(d => d.DiscountId == this.discountId && d.StateId == vehicleOwner.DLState);
                    var appliedDiscount = new VehicleDiscount
                                              {
                                                  DiscountId = discount.DiscountId,
                                                  StateId = vehicleOwner.DLState,
                                                  VehicleId = vehicle.ID,
                                                  AppliedDiscountValue = discount.Amount
                                              };

                    db.AddToVehicleDiscounts(appliedDiscount);
                }
            }

            db.SaveChanges();
        }
Ejemplo n.º 10
0
        /// <summary>
        /// This function applies the rule to a given quote.
        /// </summary>
        /// <param name="quote">The quote object that the rule should be applied to</param>
        public void Run(Quote quote)
        {
            var db = new QuotesDBEntities();

            foreach (var vehicle in quote.Vehicles)
            {
                if (vehicle.ReducedUsedDiscount)
                {
                    var vehicleOwner    = db.Drivers.Single(p => p.ID == vehicle.PrimaryDriver);
                    var discount        = db.DiscountPerStates.Single(d => d.DiscountId == this.discountId && d.StateId == vehicleOwner.DLState);
                    var appliedDiscount = new VehicleDiscount
                    {
                        DiscountId           = discount.DiscountId,
                        StateId              = vehicleOwner.DLState,
                        VehicleId            = vehicle.ID,
                        AppliedDiscountValue = discount.Amount
                    };

                    db.AddToVehicleDiscounts(appliedDiscount);
                }
            }

            db.SaveChanges();
        }
Ejemplo n.º 11
0
        public void Run(Web.Quote quote)
        {
            var db = new QuotesDBEntities();

            foreach (var vehicle in quote.Vehicles)
            {
                if (vehicle.MilesDrivenToWork < 25) //this is as in old application. doesn't correspond to excel document.
                {
                    var stateId  = (int)db.Drivers.Single(p => p.ID == vehicle.PrimaryDriver).DLState;
                    var discount =
                        db.DiscountPerStates.Single(d => d.DiscountId == this.discountId && d.StateId == stateId);
                    var appliedDiscountValue = new VehicleDiscount()
                    {
                        AppliedDiscountValue = discount.Amount,
                        DiscountId           = this.discountId,
                        StateId   = stateId,
                        VehicleId = vehicle.ID
                    };

                    db.AddToVehicleDiscounts(appliedDiscountValue);
                }
            }
            db.SaveChanges();
        }