Пример #1
0
        public PartialViewResult LoadCommentsForPost(long postId)
        {
            logginghelper.Log(LoggingLevels.Info, "Class: " + classname + " :: LoadCommentsForPost - Begin");
            List <CommentsViewModel> _lstCommentsViewModel = new List <CommentsViewModel>();

            try
            {
                List <Comment> _lstComments = dataaccess.GetCommentsByPostId(postId);
                if (_lstComments != null && _lstComments.Count > 0)
                {
                    foreach (var comment in _lstComments)
                    {
                        CommentsViewModel objCommentViewModel = new CommentsViewModel();
                        objCommentViewModel.Comment = comment;
                        if (comment.IsReply == true)
                        {
                            Reply reply = new Reply();
                            reply = dataaccess.GetReplyForComment(comment.Comment_Id);
                            objCommentViewModel.Reply = reply;
                        }
                        _lstCommentsViewModel.Add(objCommentViewModel);
                    }
                }
                ViewBag.PostId = postId;
            }
            catch (Exception ex)
            {
                logginghelper.Log(LoggingLevels.Error, "Class: " + classname + " :: LoadCommentsForPost " + ex);
            }
            logginghelper.Log(LoggingLevels.Info, "Class: " + classname + " :: LoadCommentsForPost - End");
            return(PartialView(_lstCommentsViewModel));
        }