protected override void init()
 {
     if (ArticleId.HasValue)
     {
         article = ArticlesRetrieval.GetRowMatchingId(ArticleId.Value);
     }
 }
Beispiel #2
0
        private FlowComponent getResultTable()
        {
            var results              = ShowFavorites ? ArticlesRetrieval.GetRowsLinkedToUser(UserId) : ArticlesRetrieval.GetRowsLinkedToAuthor(UserId);
            var usersById            = UsersTableRetrieval.GetRows().ToIdDictionary();
            var tagsByArticleId      = ArticleTagsTableRetrieval.GetRows().ToArticleIdLookup();
            var favoritesByArticleId = FavoritesTableRetrieval.GetRows().ToArticleIdLookup();

            var table = EwfTable.Create(defaultItemLimit: DataRowLimit.Fifty);

            table.AddData(results, i => EwfTableItem.Create(AppStatics.GetArticleDisplay(i, usersById, tagsByArticleId, favoritesByArticleId).ToCell()));
            return(table);
        }
        private string getSuffixedSlug(string slug)
        {
            var otherArticles = ArticlesRetrieval.GetRowsOrderedByCreation();

            for (var suffix = 1;; suffix += 1)
            {
                var suffixedSlug = slug + (suffix == 1 ? "" : "-{0}".FormatWith(suffix.ToString()));
                if (otherArticles.All(i => i.Slug != suffixedSlug))
                {
                    return(suffixedSlug);
                }
            }
        }
        private FlowComponent getResultTable(string filter)
        {
            var results = filter == "user" && AppTools.User != null?ArticlesRetrieval.GetRowsLinkedToFollower(AppTools.User.UserId) :
                              filter.StartsWith("tag") ? ArticlesRetrieval.GetRowsLinkedToTag(int.Parse(filter.Substring(3))) :
                              ArticlesRetrieval.GetRowsOrderedByCreation();

            var usersById            = UsersTableRetrieval.GetRows().ToIdDictionary();
            var tagsByArticleId      = ArticleTagsTableRetrieval.GetRows().ToArticleIdLookup();
            var favoritesByArticleId = FavoritesTableRetrieval.GetRows().ToArticleIdLookup();

            var table = EwfTable.Create(defaultItemLimit: DataRowLimit.Fifty);

            table.AddData(results, i => EwfTableItem.Create(AppStatics.GetArticleDisplay(i, usersById, tagsByArticleId, favoritesByArticleId).ToCell()));
            return(table);
        }
 protected override void init()
 {
     articleRow = ArticlesRetrieval.GetRowMatchingId(ArticleId);
 }