Exemplo n.º 1
0
        public async Task <ActionResult <AnswerGetViewModel> > AcceptAnswer(
            [FromRoute] Guid questionId,
            [FromRoute] Guid answerId)
        {
            var acceptAnswer = new AnswerAcceptModel
            {
                QuestionUserId = User.UserId().Value,
                QuestionId     = questionId,
                AnswerId       = answerId
            };
            var answerModel = await _answerService.AcceptAnswerAsync(acceptAnswer);

            var answerViewModel = _mapper.Map <AnswerGetViewModel>(answerModel);

            answerViewModel.IsOwner = User.IsOwner(answerViewModel);
            return(CreatedAtRoute("Get", new { questionId, answerId }, answerViewModel));
        }