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(); }
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(); }
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(); }