Ejemplo n.º 1
0
        public async Task <IViewComponentResult> InvokeAsync(Widget widget)
        {
            var blogTagsWidget = (BlogTagsWidget)widget;
            var tags           = (await _tagSvc.GetAllAsync()).Where(t => t.Count > 0).Take(blogTagsWidget.MaxTagsDisplayed);

            return(View(WidgetService.GetWidgetViewPath("BlogTags"), new Tuple <IEnumerable <Tag>, BlogTagsWidget>(tags, blogTagsWidget)));
        }
Ejemplo n.º 2
0
        public async Task <IViewComponentResult> InvokeAsync(Widget widget)
        {
            var blogCategoriesWidget = (BlogCategoriesWidget)widget;
            var categories           = (await _catSvc.GetAllAsync()).Where(t => t.Count > 0);

            return(View(WidgetService.GetWidgetViewPath("BlogCategories"),
                        new Tuple <IEnumerable <Category>, BlogCategoriesWidget>(categories, blogCategoriesWidget)));
        }
Ejemplo n.º 3
0
        public async Task <IViewComponentResult> InvokeAsync(Widget widget)
        {
            var blogArchivesWidget = (BlogArchivesWidget)widget;
            var years = await _statsSvc.GetArchivesAsync();

            return(View(WidgetService.GetWidgetViewPath("BlogArchives"),
                        new Tuple <Dictionary <int, List <MonthItem> >, BlogArchivesWidget>(years, blogArchivesWidget)));
        }
Ejemplo n.º 4
0
        public async Task <IViewComponentResult> InvokeAsync(Widget widget)
        {
            var recentBlogPostsWidget = (RecentBlogPostsWidget)widget;
            var posts = await blogPostService.GetRecentPostsAsync(recentBlogPostsWidget.NumberOfPostsToShow);

            // must have at least 2 posts
            if (posts.PostCount < 2)
            {
                return(await Task.FromResult <IViewComponentResult>(Content(string.Empty)));
            }

            // get current url
            var relativeUrl = httpContextAccessor.HttpContext.Request.Path;
            var list        = new List <RecentPostViewModel>();

            foreach (var post in posts.Posts)
            {
                // if post url is current url then skip this post
                var postUrl = BlogRoutes.GetPostRelativeLink(post.CreatedOn, post.Slug);
                if (postUrl.Equals(relativeUrl, StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                list.Add(new RecentPostViewModel
                {
                    Title   = post.Title,
                    Link    = BlogRoutes.GetPostPermalink(post.Id),
                    Author  = post.User.DisplayName,
                    Excerpt = recentBlogPostsWidget.ShowPostExcerpt ? post.Excerpt : null,
                    Date    = recentBlogPostsWidget.ShowPostDate ? post.CreatedOn.ToString("yyyy-MM-dd") : null,
                });
            }

            return(View(WidgetService.GetWidgetViewPath("RecentBlogPosts"),
                        new Tuple <List <RecentPostViewModel>, RecentBlogPostsWidget>(list, recentBlogPostsWidget)));
        }
Ejemplo n.º 5
0
        public async Task <IViewComponentResult> InvokeAsync(Widget widget)
        {
            var socialIconsWidget = (SocialIconsWidget)widget;

            return(View(WidgetService.GetWidgetViewPath("SocialIcons"), socialIconsWidget));
        }