public DbContextOptions <DiscountContext> SetupWithDiscountCriteria() { var options = new DbContextOptionsBuilder <DiscountContext>() .UseInMemoryDatabase(databaseName: "PaylocityDiscountDb") .Options; using (var context = new DiscountContext(options)) { var newDiscountCriteria = new DiscountCriteria { BaseDependentBenefitCost = 500.00m, BaseEmployeeBenefitCost = 1000.00m, DiscountPerctentageRate = .1m, DiscountQualifier = 'A', EmployeeBiWeeklyBasePay = 2000.00m, TotalYearlyCheckDisbursment = 26, CreatedOn = DateTime.UtcNow, UpdatedOn = DateTime.UtcNow }; context.Add(newDiscountCriteria); context.SaveChanges(); } return(options); }
public ActionResult New(DiscountModel model) { if (!ModelState.IsValid) { using (DiscountContext context = new DiscountContext()) { ViewBag.DiscountKinds = context.GetDiscountKinds(); } return(View("Edit", model)); } else { using (DiscountContext context = new DiscountContext()) { context.Add(model); } return(RedirectToAction("Index")); } }
public ActionResult NewGroup(DiscountGroupModel model) { if (!ModelState.IsValid) { return(View("EditGroup", model)); } else { using (DiscountContext context = new DiscountContext()) { int groupId = context.Add(model); if (groupId > 0) { context.SetGroupItems(groupId, model.DiscountList.Trim(',')); } } return(RedirectToAction("Groups")); } }