예제 #1
0
        public async Task <IActionResult> Get()
        {
            var    accessToken = _httpContextAccessor.HttpContext.Request.Headers["Authorization"].ToString().Substring(7);
            var    data        = tokenDecode.DecodeJwt(_httpContextAccessor);
            string mail        = data["Email"];
            User   user        = await _userService.GetUser(mail);

            return(Ok((new { user = user.Email, jwt = accessToken, fullName = user.FullName, number = user.PhoneNumber, imageBase64 = Encoding.UTF8.GetString(user.Filebase64) })));
        }
예제 #2
0
        public async Task <IActionResult> Post([FromBody] CommentViewModel model)
        {
            var     data     = tokenDecode.DecodeJwt(_httpContextAccessor);
            Guid    userId   = Guid.Parse(data["idUser"]);
            Comment _comment = _mapper.Map <CommentViewModel, Comment>(model);

            _comment.Id     = Guid.NewGuid();
            _comment.UserId = userId;
            await _commentService.CreateComment(_comment);

            return(Ok());
        }
예제 #3
0
        public async Task <IActionResult> Post([FromBody] RatingViewModel model)
        {
            var    data    = tokenDecode.DecodeJwt(_httpContextAccessor);
            Guid   userId  = Guid.Parse(data["idUser"]);
            Rating _rating = await _ratingService.GetRating(model.FilmId, userId);

            if (_rating == null)
            {
                Rating rating = _mapper.Map <RatingViewModel, Rating>(model);
                rating.Id     = Guid.NewGuid();
                rating.UserId = userId;
                await _ratingService.CreateRating(rating);

                return(Ok(rating.FilmId));
            }
            return(Ok(model.FilmId));
        }