Пример #1
0
        public IActionResult blogComment(long blog_id)
        {
            try
            {
                var blogsComment  = _blogCommentRepo.getQueryable().Where(a => a.blog_id == blog_id).ToList();
                var blogCommentVM = getViewModelFromBlog(blogsComment);

                return(View(blogCommentVM));
            }
            catch (Exception ex)
            {
                AlertHelper.setMessage(this, ex.Message, messageType.error);
                return(RedirectToAction("index"));
            }
        }
        public IActionResult detail(BlogsModel model)
        {
            var setupValues = _setupRepo.getQueryable().ToList();

            ViewBag.setup = setupValues;
            var notice = _noticeRepo.getQueryable().Where(n => n.notice_expiry_date >= DateTime.Now && n.is_closed == false).Take(5).ToList();

            ViewBag.notices = notice;
            try
            {
                var blogDetails = _blogRepo.getBySlug(model.slug);

                //Blog
                model.blog_id     = blogDetails.blog_id;
                model.artical_by  = blogDetails.artical_by;
                model.description = blogDetails.description;
                model.image_name  = blogDetails.image_name;
                model.posted_on   = blogDetails.posted_on;;
                model.title       = blogDetails.title;
                model.is_enabled  = blogDetails.is_enabled;
                model.slug        = blogDetails.slug;

                var blogcomments = _blogCommentRepo.getQueryable().Where(a => a.blog_id == model.blog_id).ToList();

                List <BlogComments> blogComments = new List <BlogComments>();
                foreach (var comment in blogcomments)
                {
                    BlogComments blogcomment = new BlogComments();
                    blogcomment.comments     = comment.comments;
                    blogcomment.comment_by   = comment.comment_by;
                    blogcomment.comment_date = comment.comment_date;
                    blogcomment.email        = comment.email;
                    blogComments.Add(blogcomment);
                }
                model.blog_comments = blogComments;
            }
            catch (Exception ex)
            {
                AlertHelper.setMessage(this, ex.Message, messageType.error);
            }

            return(View(model));
        }