Exemplo n.º 1
0
        public async Task <ActionResult> Get(int id)
        {
            var attractionFromRepo = await _attractionRepo.GetAttraction(id);

            var attraction = _mapper.Map <AttractionForReturnDto>(attractionFromRepo);

            attraction.ReviewPhotos = _mapper.Map <List <PhotoForReturnDto> >(await _attractionRepo.GetAllReviewPhotosForAttraction(id));
            var loggedInUser = await GetLoggedInUserAsync();

            if (loggedInUser != null)
            {
                attraction.isLiked = await _attractionRepo.AttractionLiked(loggedInUser.Id, attraction.Id);

                var currentUserReview = await _attractionRepo.GetAttractionReviewByUser(loggedInUser.Id, attraction.Id);

                if (currentUserReview != null)
                {
                    attraction.currentUsersReviewId = currentUserReview.Id;
                }
            }
            return(Ok(attraction));
        }