protected override void init()
 {
     if (ArticleId.HasValue)
     {
         article = ArticlesRetrieval.GetRowMatchingId(ArticleId.Value);
     }
 }
Beispiel #2
0
 internal static IReadOnlyCollection <FlowComponent> GetAuthorDisplay(ArticlesRetrieval.Row article, UsersTableRetrieval.Row author) =>
 new GenericFlowContainer(
     new EwfHyperlink(
         Profile.GetInfo(article.AuthorId),
         new ImageHyperlinkStyle(
             new ExternalResource(author.ProfilePictureUrl.Any() ? author.ProfilePictureUrl : "https://static.productionready.io/images/smiley-cyrus.jpg"),
             "")).Append <PhrasingComponent>(
         new GenericPhrasingContainer(
             new EwfHyperlink(Profile.GetInfo(article.AuthorId), new StandardHyperlinkStyle(author.Username))
             .Append <PhrasingComponent>(new LineBreak())
             .Append(
                 new GenericPhrasingContainer(article.CreationDateAndTime.ToDayMonthYearString(false).ToComponents(), classes: ElementClasses.Date))
             .Materialize()))
     .Materialize(),
     classes: ElementClasses.Author).ToCollection();
Beispiel #3
0
        internal static IReadOnlyCollection <FlowComponent> GetArticleDisplay(
            ArticlesRetrieval.Row article, Dictionary <int, UsersTableRetrieval.Row> usersById, ILookup <int, ArticleTagsTableRetrieval.Row> tagsByArticleId,
            ILookup <int, FavoritesTableRetrieval.Row> favoritesByArticleId)
        {
            var components = new List <FlowComponent>();

            components.Add(
                new GenericFlowContainer(
                    GetAuthorDisplay(article, usersById[article.AuthorId]).Append(getFavoriteActionComponent(article, favoritesByArticleId)).Materialize(),
                    classes: ElementClasses.ArticleListAuthorAndFavorite));

            components.Add(new Section(article.Title, new Paragraph(article.Description.ToComponents()).ToCollection()));

            components.Add(
                new GenericFlowContainer(
                    new EwfHyperlink(Article.GetInfo(article.ArticleId), new StandardHyperlinkStyle("Read more..."))
                    .Concat(GetTagDisplay(article.ArticleId, tagsByArticleId[article.ArticleId]))
                    .Materialize(),
                    classes: ElementClasses.ArticleListDetail));

            return(components);
        }
Beispiel #4
0
        private static PhrasingComponent getFavoriteActionComponent(
            ArticlesRetrieval.Row article, ILookup <int, FavoritesTableRetrieval.Row> favoritesByArticleId)
        {
            var count = favoritesByArticleId[article.ArticleId].Count().ToString();

            if (AppTools.User == null)
            {
                return(new EwfHyperlink(User.GetInfo(), new StandardHyperlinkStyle(count, icon: new ActionComponentIcon(new FontAwesomeIcon("fa-heart-o")))));
            }

            var       rs = new UpdateRegionSet();
            EwfButton button;

            if (FavoritesTableRetrieval.GetRowMatchingPk(AppTools.User.UserId, article.ArticleId, returnNullIfNoMatch: true) == null)
            {
                button = new EwfButton(
                    new StandardButtonStyle(count, icon: new ActionComponentIcon(new FontAwesomeIcon("fa-heart-o"))),
                    behavior: new PostBackBehavior(
                        postBack: PostBack.CreateIntermediate(
                            rs.ToCollection(),
                            id: PostBack.GetCompositeId("favorite", article.ArticleId.ToString()),
                            modificationMethod: () => FavoritesModification.InsertRow(AppTools.User.UserId, article.ArticleId))));
            }
            else
            {
                button = new EwfButton(
                    new StandardButtonStyle(count, icon: new ActionComponentIcon(new FontAwesomeIcon("fa-heart"))),
                    behavior: new PostBackBehavior(
                        postBack: PostBack.CreateIntermediate(
                            rs.ToCollection(),
                            id: PostBack.GetCompositeId("unfavorite", article.ArticleId.ToString()),
                            modificationMethod: () => FavoritesModification.DeleteRows(
                                new FavoritesTableEqualityConditions.UserId(AppTools.User.UserId),
                                new FavoritesTableEqualityConditions.ArticleId(article.ArticleId)))));
            }
            return(new PhrasingIdContainer(button.ToCollection(), updateRegionSets: rs.ToCollection()));
        }
 protected override void init()
 {
     articleRow = ArticlesRetrieval.GetRowMatchingId(ArticleId);
 }