public void CreateReviewTest() { Review r = new Review(100, "Added by test", 5.9m, DateTime.Now, 123, 132); int res = Repo.CreateReview(r); Assert.AreEqual(100, res); }
public Review CreateReview(Review review) { var reviewMovie = reviewRepo.CreateReview(review); var result = AutoMapper.Mapper.Map <Review, ReviewDto>(reviewMovie); reviewRepo.Save(); return(reviewRepo.CreateReview(review)); //reviewRepo.CreateReview(review); }
public void DeleteReview() { try { // Arrange var reviewRepository = new ReviewRepository(RestaurantReviewsContext); var newReview = new Review { Comment = "Good food.", Rating = 4, RestaurauntId = DataSeeder.Restaurants[0].Id, SubmissionDate = DateTime.UtcNow, UserId = DataSeeder.Users[0].Id }; reviewRepository.CreateReview(newReview).Wait(); var savedReview = reviewRepository.GetReviewById(newReview.Id).Result; Assert.IsNotNull(savedReview, string.Format("Review {0} was not saved in the database", newReview.Id)); Assert.IsTrue(savedReview.Comment == newReview.Comment, string.Format("Review({0}).Comment was not saved in the database", newReview.Id)); // Act reviewRepository.DeleteReview(savedReview).Wait(); // Assert var shouldBeDeletedReview = reviewRepository.GetReviewById(newReview.Id).Result; Assert.IsTrue(shouldBeDeletedReview.IsEmptyObject(), string.Format("Review({0}) was not deleted from the database", newReview.Id)); } catch (Exception ex) { Assert.Fail(string.Format("An unexpected exception occurred in DeleteReview {0}", ex.Message)); } }
public void TestCreateReview() { var sql = new ReviewSqlContext(); var repo = new ReviewRepository(sql); var review = new Review(1, 4, "Tralala", 8); int i = repo.CreateReview(review); Assert.AreEqual(6, i); }
public ActionResult New(FormCollection form) { ReviewSqlContext sql = new ReviewSqlContext(); ReviewRepository repo = new ReviewRepository(sql); string omschrijving = form["omschrijving"]; int beoordeling = Convert.ToInt32(form["beoordeling"]); int vrijwilligerId = Convert.ToInt32(form["vrijwilligerId"]); int hulpbehoevendeId = Convert.ToInt32(form["hulpbehoevendeId"]); Review newReview = new Review(hulpbehoevendeId, vrijwilligerId, omschrijving, beoordeling); repo.CreateReview(newReview); return(Redirect(Request.UrlReferrer.ToString())); }
public IActionResult Create([FromBody] ReviewCreateViewModel vm) { vm.PostedBy = Convert.ToInt32(this.User.FindFirstValue(ClaimTypes.NameIdentifier)); vm.DatePosted = DateTime.Now; Review R = Converter.ReviewCreateViewModelToReview(vm); int id = Repo.CreateReview(R); ReviewViewModel result = new ReviewViewModel() { ReviewId = id, PostedById = vm.PostedBy, Body = vm.Body, Rating = vm.Rating, BookReviewed = vm.BookReviewed, DatePosted = vm.DatePosted, PostedBy = User.Identity.Name }; return(PartialView("_Detail", result)); }