Esempio n. 1
0
        public async Task <IActionResult> AddLike(int questionId)
        {
            var userId = _userManager.GetUserId(User);
            var user   = await _userManager.FindByIdAsync(userId);

            var likeQuestion = BuildLike(questionId, user);

            await _questionImplementation.AddLike(likeQuestion);

            var question = _questionImplementation.GetById(questionId);
            var model    = new QuestionIndexModel
            {
                LikeCount  = question.LikeQuestions.Count(),
                QuestionId = question.QuestionId
            };

            return(RedirectToAction("Index", "Question", new { id = questionId }));
        }