public void TestAddReviewToBookOk() { //SETUP var options = SqliteInMemory.CreateOptions <EfCoreContext>(); using (var context = new EfCoreContext(options)) { context.Database.EnsureCreated(); context.SeedDatabaseFourBooks(); } using (var context = new EfCoreContext(options)) { var service = new AddReviewService(context); //ATTEMPT var dto = service.GetOriginal(1); dto.NumStars = 2; service.AddReviewToBook(dto); context.SaveChanges(); //VERIFY context.Set <Review>().Count().ShouldEqual(3); context.Books.Include(x => x.Reviews).Single(x => x.BookId == 1).Reviews.Single().NumStars.ShouldEqual(2); } }
public IActionResult AddBookReview(Review review) { Request.ThrowErrorIfNotLocal(); var service = new AddReviewService(dataContext); var updatedReview = service.AddReviewToBook(review); return(View("BookUpdated", "Successfully added a review")); }
public IActionResult AddBookReview(Review dto) { Request.ThrowErrorIfNotLocal(); var service = new AddReviewService(_context); var book = service.AddReviewToBook(dto); SetupTraceInfo(); return(View("BookUpdated", "Successfully added a review")); }