Beispiel #1
0
        public async Task <IActionResult> GetReviews(int id)
        {
            // if (id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            //     return Unauthorized();

            var reviews = await _repo.GetReviews(id);

            var reviewDetail = _mapper.Map <IEnumerable <ReviewForDetailDto> >(reviews).ToList();

            var reviewUsers = await _repo.GetUserDetailForReviews(reviews.Select(x => x.UserId).ToArray());

            var reviewUSerslist = reviewUsers.ToList();

            for (int i = 0; i < reviewDetail.Count; i++)
            {
                reviewDetail[i].Email    = reviewUSerslist[i].Email;
                reviewDetail[i].PhotoUrl = reviewUSerslist[i].PhotoUrl;
                reviewDetail[i].Username = reviewUSerslist[i].Username;
            }

            return(Ok(reviewDetail));
        }