public void Run(Web.Quote quote)
        {
            var db = new QuotesDBEntities();

            foreach (var vehicle in quote.Vehicles)
            {
                if (vehicle.AntiLock)
                {
                    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();
        }
        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();
        }
Beispiel #3
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();
        }
Beispiel #5
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();
        }
Beispiel #6
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();
        }