public IActionResult ChangePromotion(int id) { Request.ThrowErrorIfNotLocal(); var service = new ChangePriceOfferService(_context); var priceOffer = service.GetOriginal(id); ViewData["BookTitle"] = service.OrgBook.Title; ViewData["OrgPrice"] = service.OrgBook.Price < 0 ? "Not currently for sale" : service.OrgBook.Price.ToString("c", new CultureInfo("en-US")); SetupTraceInfo(); return(View(priceOffer)); }
public void TestGetOriginal(int bookIndex, bool hasPromotion) { //SETUP var options = SqliteInMemory.CreateOptions <EfCoreContext>(); using (var context = new EfCoreContext(options)) { context.Database.EnsureCreated(); var books = context.SeedDatabaseFourBooks(); var service = new ChangePriceOfferService(context); //ATTEMPT var priceOffer = service.GetOriginal(books[bookIndex].BookId); //VERIFY (priceOffer.NewPrice != books[bookIndex].Price).ShouldEqual(hasPromotion); } }
public void AddRemovePriceOffer(int bookIndex, int numPriceOffers) { //SETUP var options = SqliteInMemory.CreateOptions <EfCoreContext>(); using (var context = new EfCoreContext(options)) { context.Database.EnsureCreated(); var books = context.SeedDatabaseFourBooks(); var service = new ChangePriceOfferService(context); var priceOffer = service.GetOriginal(books[bookIndex].BookId); //ATTEMPT var error = service.AddRemovePriceOffer(priceOffer); //VERIFY context.PriceOffers.Count().ShouldEqual(numPriceOffers); } }