public void StaffelDiscountTestInitialize() { VipServicesContextTest contextTest = new VipServicesContextTest(keepExistingDB: false); VipServicesManager m = new VipServicesManager(new UnitOfWork(contextTest)); CategoryType vip = CategoryType.vip; StaffelDiscount staffel1 = new StaffelDiscount(2, 5, vip); StaffelDiscount staffel2 = new StaffelDiscount(7, 7.5, vip); StaffelDiscount staffel3 = new StaffelDiscount(15, 10, vip); m.AddStaffel(staffel1); m.AddStaffel(staffel2); m.AddStaffel(staffel3); CategoryType planner = CategoryType.huwelijksplanner; StaffelDiscount staffel4 = new StaffelDiscount(5, 7.5, planner); StaffelDiscount staffel5 = new StaffelDiscount(10, 10, planner); StaffelDiscount staffel6 = new StaffelDiscount(15, 12.5, planner); StaffelDiscount staffel7 = new StaffelDiscount(20, 15, planner); StaffelDiscount staffel8 = new StaffelDiscount(25, 25, planner); m.AddStaffel(staffel4); m.AddStaffel(staffel5); m.AddStaffel(staffel6); m.AddStaffel(staffel7); m.AddStaffel(staffel8); }
public void AddStaffel_ShouldWork() { VipServicesContextTest contextTest = new VipServicesContextTest(keepExistingDB: false); VipServicesManager m = new VipServicesManager(new UnitOfWork(contextTest)); StaffelDiscount staffelDiscount = new StaffelDiscount(5, 5, CategoryType.concertpromotor); Action act = () => { m.AddStaffel(staffelDiscount); }; act.Should().NotThrow <Exception>(); Assert.AreEqual(1, contextTest.StaffelDiscounts.Local.Count); var staffelInDB = contextTest.StaffelDiscounts.First(); Assert.AreEqual(staffelInDB.Category, CategoryType.concertpromotor); Assert.AreEqual(staffelInDB.NumberOfBookedReservations, 5); Assert.AreEqual(staffelInDB.DiscountPercentage, 5); }
/// <summary> /// Gets the current discount used for the client. /// </summary> /// <returns>A float representing the used discount.</returns> public float GetDiscount() { if (PastReservations.Any(d => d.Year == DateTime.Now.Year)) { if (PastReservations.Single(d => d.Year == DateTime.Now.Year).NrOfReservations == 0) { return(0); } else { var toReturn = StaffelDiscount.Where(s => s.NrOfReservationsNeeded < PastReservations.Single(d => d.Year == DateTime.Now.Year).NrOfReservations).Last().Discount; return(toReturn); } } else { PastReservations.Add(new ReservationsPerYear(DateTime.Now.Year, 0)); return(0); } }
/// <summary> /// Deze method voegt een Staffel toe aan de DB /// </summary> public void AddStaffel(StaffelDiscount staffelDiscount) { uow.StaffelDiscounts.AddStaffel(staffelDiscount); uow.Complete(); }
public void AddStaffel(StaffelDiscount staffel) { context.StaffelDiscounts.Add(staffel); }