示例#1
0
        public PartialViewResult Comments(int id)
        {
            List <CommentListVM> model = new List <CommentListVM>();
            var queryResult            = this.repos.GetComments(id);

            if (ModelState.IsValid && queryResult != null)
            {
                foreach (var comment in queryResult)
                {
                    CommentListVM current = new CommentListVM();
                    current.Messages            = new CommentsTree();
                    current.Messages.CommentID  = comment.CommentID;
                    current.Messages.ArticleID  = comment.ArticleID;
                    current.Messages.Content    = comment.Content;
                    current.Messages.CreateDate = comment.CreateDate;
                    current.Messages.UserID     = comment.UserID;
                    current.Messages.Parent     = comment.Parent;
                    current.Messages.IdDeleted  = comment.IdDeleted;

                    if (comment.ChildNodes != null)
                    {
                        current.Messages.ChildNodes = new List <DAL.TableModels.Comments>();
                        foreach (var child in comment.ChildNodes)
                        {
                            current.Messages.ChildNodes.Add(child);
                        }
                    }

                    model.Add(current);
                }
                return(PartialView("Comments", model));
            }

            return(null);
        }
示例#2
0
        public ActionResult Index(int?page, int?articleId, string Keyword)
        {
            var commentListVM = new CommentListVM();

            commentListVM.ArticleId = articleId ?? 0;
            commentListVM.PageIndex = (page ?? 1);
            commentListVM.PageSize  = SettingsManager.Article.PageSize;
            commentListVM.Keyword   = Keyword;

            int count;
            var comments = _commentServices.GetPagedElements(commentListVM.PageIndex - 1, commentListVM.PageSize, commentListVM.Keyword, (int)commentListVM.ArticleId, out count);



            //   commentListVM.Comments = commentDtos;
            commentListVM.TotalCount = count;

            //var categoryList = _categoryServices.GetAll().OrderByDescending(c => c.Importance).ToList();
            //var categories = new SelectList(categoryList, "Id", "Title");
            //ViewBag.Categories = categories;

            commentListVM.Comments = new StaticPagedList <Comment>(comments, commentListVM.PageIndex, commentListVM.PageSize, commentListVM.TotalCount);

            ViewBag.PageSizes = new SelectList(Site.PageSizes());

            return(View(commentListVM));
        }
        public DataTable List(CommentListVM listVM)
        {
            try
            {
                SqlParameter[] param = new SqlParameter[3];
                param[0] = new SqlParameter("@DocumentID", listVM.DocumentID);
                param[1] = new SqlParameter("@PageIndex", listVM.PageIndex);
                param[2] = new SqlParameter("@PageSize", listVM.PageSize);

                return(SQLHelper.GetDataTable(CommandType.StoredProcedure, "app.spGetComments", param));
            }
            catch (Exception e) { throw; }
        }
        public IActionResult GetGridItems(int page = 1)
        {
            var entities = _commentRepository.GetMainComments();

            var comments = _mapper.Map <List <CommentListItemVM> >(entities);

            var model = new CommentListVM()
            {
                Comments = comments.ToPagedList(page, 10)
            };

            return(PartialView("_Comments", model));
        }
        public IActionResult Index()
        {
            var entities = _commentRepository.GetMainComments();

            var comments = _mapper.Map <List <CommentListItemVM> >(entities);

            var model = new CommentListVM()
            {
                Comments = comments.ToPagedList(1, 10)
            };

            return(View(model));
        }
        public Result <List <Comment> > List(CommentListVM listVM)
        {
            List <Comment> comment = new List <Comment>();
            var            model   = ConvertDataTableToList.BindList <Comment>(_dataSource.List(listVM));

            if (model.Count > 0)
            {
                for (int i = 0; i < model.Count; i++)
                {
                    comment.Add(new Comment {
                        ID = model[i].ID, Body = model[i].Body, CreationDate = model[i].CreationDate, DisLikeCount = model[i].DisLikeCount, CommentType = model[i].CommentType, LikeCount = model[i].LikeCount, Children = List(model[i].ID, model[i].DocumentID).Data, ParentID = model[i].ParentID
                    });
                }
                var list = comment.Where(x => x.ParentID == Guid.Empty).Select(x => x).ToList();
                return(Result <List <Comment> > .Successful(data : list));
            }
            else
            {
                return(Result <List <Comment> > .Failure(data : comment));
            }
        }