public static Uri ForumPostUri(ForumFeedModel topFeedItem, int pageCount, ForumPost mostRecentPostToTopThread) { return new Uri(string.Format(LinkFormat, topFeedItem.ForumSubCategory.SubForumURL, ((pageCount > 1) ? "/" + pageCount.ToString(CultureInfo.InvariantCulture) : string.Empty), mostRecentPostToTopThread.ForumPostID.ToString(CultureInfo.InvariantCulture))); }
public static Uri ForumPostUrl(ForumPost lastPost, ForumFeedModel feedItem, int pageCount) { return (lastPost == null) ? feedItem.ForumSubCategory.SubForumURL : new Uri(string.Format(LinkFormat, feedItem.ForumSubCategory.SubForumURL, ((pageCount > 1) ? "/" + pageCount.ToString(CultureInfo.InvariantCulture) : string.Empty), lastPost.ForumPostID.ToString(CultureInfo.InvariantCulture))); }
private ForumFeedModel LoadMostPopularThisWeek( IGrouping<int, ForumPost> mostPopularThisWeek, DasKlubDbContext context, UserAccount ua) { ForumSubCategory topForumThreadOfTheWeek = (mostPopularThisWeek != null) ? context.ForumSubCategory.FirstOrDefault(x => x.ForumSubCategoryID == mostPopularThisWeek.Key) : null; if (topForumThreadOfTheWeek == null) return null; var topFeedItem = new ForumFeedModel { ForumSubCategory = topForumThreadOfTheWeek }; // the thread itself is a post //topFeedItem.PostCount = 1; topFeedItem.PostCount = topFeedItem.ForumSubCategory.PostCount; topFeedItem.ForumCategory = context.ForumCategory.FirstOrDefault( x => x.ForumCategoryID == topFeedItem.ForumSubCategory.ForumCategoryID); ForumPost mostRecentPostToTopThread = context.ForumPost.OrderByDescending(x => x.CreateDate) .FirstOrDefault( x => x.ForumSubCategoryID == topFeedItem.ForumSubCategory.ForumSubCategoryID); if (mostRecentPostToTopThread != null) { var lastUser = new UserAccount(mostRecentPostToTopThread.CreatedByUserID); topFeedItem.UserName = lastUser.UserName; topFeedItem.UserAccount = lastUser; topFeedItem.LastPosted = mostRecentPostToTopThread.CreateDate; } if (ua == null) return topFeedItem; ForumPostNotification isNew = context.ForumPostNotification.FirstOrDefault( x => x.ForumSubCategoryID == topForumThreadOfTheWeek.ForumSubCategoryID && x.UserAccountID == ua.UserAccountID); if (isNew == null || isNew.IsRead) return topFeedItem; topFeedItem.IsNewPost = true; int forumSubPostCount = context.ForumPost.Count( x => x.ForumSubCategoryID == topFeedItem.ForumSubCategory.ForumSubCategoryID); int pageCount = (forumSubPostCount + ForumController.PageSize - 1) / ForumController.PageSize; if (mostRecentPostToTopThread != null) { topFeedItem.URLTo = LinkHelper.ForumPostUri(topFeedItem, pageCount, mostRecentPostToTopThread); } return topFeedItem; }