Пример #1
0
        public ActionResult Rating([FromQuery] int vote, [FromQuery] int postId)
        {
            try
            {
                var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;

                var addedRating = postRatingService.IsAddedRating(userId, postId, vote);

                if (addedRating)
                {
                    postService.AddRating(postId, vote);

                    return(Ok());
                }
                else
                {
                    return(Forbid());
                }
            }
            catch
            {
                return(Unauthorized());
            }
        }