Exemplo n.º 1
0
        public List <BlogVM> BlogVMList()
        {
            var blogs = blogRepository.GetAll();
            var model = new List <BlogVM>();

            foreach (var item in blogs)
            {
                model.Add(new BlogVM
                {
                    _Blog = item
                });
            }
            for (int i = 0; i < blogs.Count; i++)
            {
                if (model[i] != null)
                {
                    int id = model[i]._Blog.BlogId;
                    model[i]._BlogComment = blogCommentRepository.GetByFilter(x => x.BlogId == id).ToList();
                    model[i]._Picture     = pictureRepository.GetByFilterx(x => x.BlogId == id);
                }
            }

            return(model);
        }
Exemplo n.º 2
0
        public ActionResult Detail(int id)
        {
            BlogRepository        blogRepository        = new BlogRepository();
            BlogPhotoRepository   blogPhotoRepository   = new BlogPhotoRepository();
            BlogCommentRepository blogCommentRepository = new BlogCommentRepository();

            BlogDetailViewModel blogView = new BlogDetailViewModel();
            var blogresult        = blogRepository.GetById(id);
            var blogphotoresult   = blogPhotoRepository.GetByFilter(X => X.BlogId == id);
            var blogcommentresult = blogCommentRepository.GetByFilter(x => x.BlogId == id);

            blogView.Content      = blogresult.Content;
            blogView.Star         = blogresult.Star;
            blogView.Title        = blogresult.Title;
            blogView.RegisterDate = blogresult.RegisterDate;
            blogView.UserId       = blogresult.UserId;
            blogView.Users        = blogresult.Users;
            blogView.blogComment  = blogcommentresult;
            blogView.blogPhoto    = blogphotoresult;
            return(View(blogView));
        }