public IActionResult Details(int id, Answer.SortField sort = AskMate.Common.Domain.Answer.SortField.SubmissionTime, bool ascending = false) { int?userId = int.TryParse(HttpContext.User.FindFirstValue("Id"), out var i) ? i : (int?)null; var question = _questionsService.GetOne(id); var tags = _tagsService.GetAll(id); var answers = _answersService.GetAll(new IAnswersService.GetAllOptions(sort, ascending) { QuestionId = id }); var questionComments = _commentsService.GetAll(ICommentsService.CommentType.Question, id); var answerComments = _commentsService.GetAll(ICommentsService.CommentType.Answer, answers.Select(x => x.Id).ToArray()); _questionsService.View(userId, id); return(View(new QuestionDetailModel(question, tags, questionComments, answers, answerComments))); }
public GetAllOptions(Answer.SortField sort, bool ascending) { Sort = sort; Ascending = ascending; }