public async Task <IActionResult> AnswerAsync(int id, string answerText) { if (string.IsNullOrWhiteSpace(answerText)) { return(BadRequest()); } if (!User.Identity.IsAuthenticated) { return(Forbid()); } string userId = (await _userManager.GetUserAsync(User)).Id; QuestionViewModel?question = (await _questionService.GetQuestionsForUserAsync(userId, hasReplies: false)).FirstOrDefault(q => q.Id == id); // TODO: get by id directly?? if (question == null) { return(NotFound()); } ApplicationUser replyWriter = await _userManager.GetUserAsync(User); // TODO: GetUserAsync already called before. Re-use the value await _questionService.AnswerQuestionAsync(id, answerText, replyWriter); return(RedirectToAction("UserProfile", "User", new { username = User.Identity.Name })); }