Exemplo n.º 1
0
        public IActionResult Author(string slug, int page = 1)
        {
            var pager   = new Pager(page);
            var profile = _db.Profiles.Single(p => p.Slug == slug);
            var posts   = _db.BlogPosts.Find(p => p.ProfileId == profile.Id && p.Published > DateTime.MinValue, pager);

            if (page < 1 || page > pager.LastPage)
            {
                return(View(_theme + "Error.cshtml", 404));
            }

            var cf = _custom.GetProfileCustomFields(profile).Result;

            return(View("~/Views/Blogifier/Blog/" + profile.BlogTheme + "/Author.cshtml",
                        new BlogAuthorModel {
                CustomFields = cf, Profile = profile, Posts = posts, Pager = pager
            }));
        }
Exemplo n.º 2
0
        public BlogAuthorModel GetPostsByAuthor(string auth, int page, bool pub = false)
        {
            var pager   = new Pager(page);
            var profile = _db.Profiles.Single(p => p.Slug == auth);
            var posts   = _db.BlogPosts.Find(p => p.ProfileId == profile.Id && p.Published > DateTime.MinValue, pager);

            if (page < 1 || page > pager.LastPage)
            {
                return(null);
            }

            if (pub)
            {
                posts = SantizePostListItems(posts);
            }

            return(new BlogAuthorModel
            {
                CustomFields = _custom.GetProfileCustomFields(profile).Result,
                Profile = profile,
                Posts = posts,
                Pager = pager
            });
        }