public ActionResult <Review> GetReviewById(int id) { var reviewItems = reviewRepo.GetReviewById(id); if (reviewItems != null) { return(Ok(mapper.Map <ReviewReadDto>(reviewItems))); } return(NotFound()); }
public ActionResult DeleteReview(int id) { var reviewToDelete = _repo.GetReviewById(id); if (HttpContext.User.IsInRole("admin") || int.Parse(HttpContext.User.Identity.GetAuthorId().Remove(0, 10)) == reviewToDelete.AuthorId) { return(View(reviewToDelete)); } else { return(RedirectToAction("Index", "Reviews")); } }
// Returns Create View based on a review id, cannot create a // report without a review -- for now // GET: Reports/Create public async Task <IActionResult> Create(int id) { Review review = reviewRepo.GetReviewById(id); AppUser user = await userManager.FindByNameAsync(review.Reviewer); ViewBag.reportedUser = user.UserName; return(View()); }
public ActionResult <ReviewReadDto> GetReviewById(int id) { var reviewItem = _repository.GetReviewById(id); if (reviewItem == null) { return(NotFound()); } return(Ok(_mapper.Map <ReviewReadDto>(reviewItem))); }
public IActionResult GetReview(int userId, int recipeId) { if (!ReviewExists(userId, recipeId)) { _logger.LogWarning($"Review with user id: {userId} and recipe id: {recipeId} does not exist."); return(NotFound()); } Review review = _reviewRepo.GetReviewById(userId, recipeId); _logger.LogInformation($"Getting review with user id: {userId} and recipe id: {recipeId}."); return(Ok(review)); }
public void TestGetReviewById() { //Arrange repo = new FakeReviewRepo(); SeedReviewData(); foreach (Review r in reviews) { repo.AddReview(r); } //Act Review stilesHP = repo.GetReviewById(2); //Assert Assert.Equal("Harry Potter and the Sorceror's Stone", stilesHP.BookTitle); Assert.Equal("Stiles", stilesHP.Reviewer); Assert.NotEqual("TeenWolf", stilesHP.Reviewer); }
public ActionResult Details(int id) { return(View(_repo.GetReviewById(id))); }