Beispiel #1
0
        public IActionResult GetReviewerById(int reviewerId)
        {
            if (!_reviewerRepository.Exists(reviewerId))
            {
                return(NotFound());
            }

            var reviewer = _reviewerRepository.GetReviewerById(reviewerId);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var reviewerDto = new ReviewerDto()
            {
                Id        = reviewer.Id,
                FirstName = reviewer.FirstName,
                LastName  = reviewer.LastName
            };

            return(Ok(reviewerDto));
        }
Beispiel #2
0
        public IActionResult GetReviewById(int reviewId)
        {
            if (!_reviewerRepository.Exists(reviewId))
            {
                return(BadRequest());
            }

            var review = _reviewRepository.GetReviewById(reviewId);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var reviewDto = new ReviewDto()
            {
                Id         = review.Id,
                Headline   = review.Headline,
                ReviewText = review.ReviewText,
                Rating     = review.Rating,
            };

            return(Ok(reviewDto));
        }