示例#1
0
        public async Task <IActionResult> GetCommentsByUser(string userId)
        {
            if (userId == null)
            {
                return(NotFound());
            }
            var comments = await _service.AllCommentsByUser(userId);

            var movieComments = _mapper.Map <ICollection <Comment>, List <CommentGetByUserDto> >(comments);

            return(Ok(movieComments));
        }
示例#2
0
        public async Task <IActionResult> GetAllUserInformation()
        {
            //Todo: Firebase stores information like created date. I don't know how to retrieve those information.

            var userIdFromToken = this.User.GetUserId();

            if (userIdFromToken == null)
            {
                return(Unauthorized());
            }

            var userExists = await _userService.UserExist(userIdFromToken);

            if (!userExists)
            {
                return(NotFound());
            }

            var trackedMovies = await _trackService.GetTrackedMoviesByUser(userIdFromToken);

            var writtenComments = await _commentService.AllCommentsByUser(userIdFromToken);

            var user = await _userService.GetUser(userIdFromToken);

            var trackedMoviesToReturn   = _mapper.Map <ICollection <TrackedMovie>, List <MovieTrackGdprDto> >(trackedMovies);
            var writtenCommentsToReturn = _mapper.Map <ICollection <Comment>, List <MovieCommentGdprDto> >(writtenComments);
            var userToReturn            = _mapper.Map <User, UserGdprDto>(user);

            var bundledInfoToReturn = new UserAllDataGetDto()
            {
                User          = userToReturn,
                TrackedMovies = trackedMoviesToReturn,
                Comments      = writtenCommentsToReturn
            };

            return(Ok(bundledInfoToReturn));
        }