public virtual ActionResult Index(PostsListType listType, int?page, int?pageSize, int?catId, DateTime?fromDate) { IPagedList <TblPosts> posts = null; switch (listType) { case PostsListType.Newest: posts = _postService.GetNewItems(page ?? 1, pageSize ?? 50, catId, fromDate); break; case PostsListType.MostPopular: posts = _postService.GetPopularItems(page ?? 1, pageSize ?? 50, catId, fromDate); break; case PostsListType.HotList: posts = _postService.GetHotList(page ?? 1, pageSize ?? 50, catId, fromDate); break; case PostsListType.Featured: posts = _postService.GetFeaturedItems(page ?? 1, pageSize ?? 50, catId, fromDate); break; } var feed = new SyndicationFeed(CurrentSettings.GetLocalized(x => x.SiteName), CurrentSettings.GetLocalized(x => x.SiteDescription), new Uri(Url.Action("Index", "Home", null, Request.Url.Scheme))); List <SyndicationItem> items = new List <SyndicationItem>(); foreach (var post in posts) { Uri url = new Uri(Url.Action("Index", "Search", new SearchTermModel() { PostType = null, OrderBy = SearchResultSortType.Score, SearchPlace = SearchPlace.Title, Query = post.Title }, Request.Url.Scheme)); if (post.PostType == PostType.BlogPost) { url = new Uri(Url.Action("Post", "Blog", new { slug = post.Slug }, Request.Url.Scheme)); } if (post.PostType == PostType.Product) { url = new Uri(Url.Action("Index", "Product", new { slug = post.Slug }, Request.Url.Scheme)); } var item = new SyndicationItem( post.GetLocalized(p => p.Title).EscapeXml(), (post.Descriptions?.OrderBy(p => p.DisplayOrder) ?.FirstOrDefault() ?.GetLocalized(p => p.HtmlDescription) ?? " - ").EscapeXml(), url, post.Id.ToString(), post.LastUpDate ?? post.PublishDate); items.Add(item); } feed.Items = items; return(new RssActionResult(new Rss20FeedFormatter(feed))); }
public virtual ActionResult BlogExplorer(PostsListType listType, int?page, int?pageSize, int?catId, DateTime?fromDate) { if (!CurrentSettings.EnableBlog) { return(View("PageNotFound")); } return(View(new PostsExplorerModel() { PageIndex = page ?? 1, PageSize = pageSize, PostsListType = listType, FilterByCategoryId = catId, FromDate = fromDate })); }
public virtual ActionResult GetBlogPostsList(PostsListType listType, int?page, int?pageSize, int?catId, DateTime?fromDate, ViewStyles?style, NumberOfCol?numberOfCol, bool?showPager) { if (!CurrentSettings.EnableBlog) { return(View("PageNotFound")); } var currentUser = UserManager.FindById(User.Identity.GetUserId()); IPagedList <TblBlogPosts> posts = null; switch (listType) { case PostsListType.Newest: posts = _blogPostService.GetNewItems(page ?? 1, pageSize ?? 24, catId, fromDate); break; case PostsListType.MostPopular: posts = _blogPostService.GetPopularItems(page ?? 1, pageSize ?? 24, catId, fromDate); break; case PostsListType.HotList: posts = _blogPostService.GetHotList(page ?? 1, pageSize ?? 24, catId, fromDate); break; case PostsListType.Featured: posts = _blogPostService.GetFeaturedItems(page ?? 1, pageSize ?? 24, catId, fromDate); break; } var model = new PostsListModel() { PostsList = _postModelFactory.PreparePostCardViewModel(posts, currentUser, Url), ViewStyle = style ?? ViewStyles.Normal, PageIndex = page ?? 1, PageSize = pageSize, PostsListType = listType, FromDate = fromDate, FilterByCategoryId = catId, ShowPager = showPager ?? true, NumberOfCol = numberOfCol ?? NumberOfCol.Four }; return(View("Partials/_PostsList", model)); }
public virtual ActionResult Blog(PostsListType listType, int?page, int?pageSize, int?catId, DateTime?fromDate) { IPagedList <TblBlogPosts> posts = null; switch (listType) { case PostsListType.Newest: posts = _blogPostService.GetNewItems(page ?? 1, pageSize ?? 50, catId, fromDate); break; case PostsListType.MostPopular: posts = _blogPostService.GetPopularItems(page ?? 1, pageSize ?? 50, catId, fromDate); break; case PostsListType.HotList: posts = _blogPostService.GetHotList(page ?? 1, pageSize ?? 50, catId, fromDate); break; case PostsListType.Featured: posts = _blogPostService.GetFeaturedItems(page ?? 1, pageSize ?? 50, catId, fromDate); break; } var feed = new SyndicationFeed(CurrentSettings.GetLocalized(x => x.SiteName), CurrentSettings.GetLocalized(x => x.SiteDescription), new Uri(Url.Action("Index", "Home", null, Request.Url.Scheme))); var items = Enumerable.Select(posts, post => new SyndicationItem( post.GetLocalized(p => p.Title).EscapeXml(), (post.Descriptions?.OrderBy(p => p.DisplayOrder) ?.FirstOrDefault() ?.GetLocalized(p => p.HtmlDescription) ?? " - ").EscapeXml(), new Uri(Url.Action("Post", "Blog", new { slug = post.Slug }, Request.Url.Scheme)), post.Id.ToString(), post.LastUpDate ?? post.PublishDate)) .ToList(); feed.Items = items; return(new RssActionResult(new Rss20FeedFormatter(feed))); }