Ejemplo n.º 1
0
        public BlogsByUserViewModel LoadBlogsByUser(String userName)
        {
            var blogModel = new BlogsByUserViewModel
            {
                BlogUsername = userName.Replace(ContentGlobals.BLOGDELIMMETER, " ")
            };

            // Get User based on authorid
            blogModel.TheBlogUser = _context.BlogUsers.FirstOrDefault(x => x.Username == blogModel.BlogUsername);

            var model = new BlogListModel(_context);
            blogModel.MaxBlogCount = model.GetBlogSettings().MaxBlogsOnHomepageBeforeLoad;
            blogModel.SkipBlogs = blogModel.MaxBlogCount;
            blogModel.BlogTitle = model.GetBlogSettings().BlogTitle;

            blogModel.AllBlogs = _context.Blogs.Where(x => x.BlogAuthor.Username == blogModel.BlogUsername && x.IsActive).ToList();

            blogModel.BlogsByUser = blogModel.AllBlogs
                        .OrderByDescending(blog => blog.Date)
                        .Take(blogModel.MaxBlogCount)
                        .ToList();

            // Try permalink first
            blogModel.TheBlog = blogModel.BlogsByUser.FirstOrDefault(x => x.BlogAuthor.Username == blogModel.BlogUsername);

            return blogModel;
        }
Ejemplo n.º 2
0
        public ActionResult User(string username)
        {
            var model = new BlogsByUserViewModel(username);

            return View("~/Views/Blog/BlogsByUser.cshtml", model);
        }