コード例 #1
0
ファイル: ProblemAJAXController.cs プロジェクト: hqt/MathHub
        public virtual ActionResult Answer(int postId, int offset)
        {
            IEnumerable<Reply> answers = _problemQueryService.GetAllReplies(
                    postId,
                    ReplyEnum.ANSWER,
                    offset,
                    Constant.DEFAULT_PER_PAGE
                ).AsEnumerable();

            ICollection<AnswerItemVM> answerItemVms = answers
                .Select(Mapper.Map<Reply, AnswerItemVM>)
                .ToList();

            // this mapping must be have
            // if not. strange error will be appear at ViewModel in View
            foreach (AnswerItemVM am in answerItemVms) {
                am.CommentPostVm = new CommentPostVM();
                am.CommentPostVm.ReplyId = am.Id;
                am.CommentPostVm.Type = EnumCommentType.REPLY;
            }

            AnswerListVM answerListVm = new AnswerListVM();
            answerListVm.AnswerItemVms = answerItemVms;
            return PartialView("Partials/_AnswerList", answerListVm);
        }
コード例 #2
0
ファイル: DiscussionController.cs プロジェクト: hqt/MathHub
        public virtual ActionResult Reply(int id, int offset)
        {
            IEnumerable<Reply> replies = _discussionQueryService.GetAllReplies(
                    id,
                    ReplyEnum.DEFAULT,
                    offset,
                    Constant.DEFAULT_PER_PAGE
                ).AsEnumerable();

            ICollection<AnswerItemVM> answerItemVms = replies.Select(Mapper.Map<Reply, AnswerItemVM>).ToList();
            AnswerListVM answerListVm = new AnswerListVM();
            answerListVm.AnswerItemVms = answerItemVms;
            return PartialView("Partials/_AnswerList", answerListVm);
        }