private IReadOnlyCollection <FlowComponent> getCommentComponents()
        {
            var components = new List <FlowComponent>();

            var createUpdateRegions = new UpdateRegionSet();

            components.AddRange(getNewCommentComponents(createUpdateRegions));

            var usersById = UsersTableRetrieval.GetRows().ToIdDictionary();

            components.Add(
                new StackList(
                    CommentsTableRetrieval.GetRows(new CommentsTableEqualityConditions.ArticleId(ArticleId))
                    .OrderByDescending(i => i.CommentId)
                    .Select(
                        i => {
                var deleteUpdateRegions = new UpdateRegionSet();
                return(new Paragraph(i.BodyText.ToComponents()).Append(getCommentFooter(i, usersById[i.AuthorId], deleteUpdateRegions))
                       .Materialize()
                       .ToComponentListItem(i.CommentId.ToString(), removalUpdateRegionSets: deleteUpdateRegions.ToCollection()));
            }),
                    setup: new ComponentListSetup(
                        classes: ElementClasses.Comment,
                        itemInsertionUpdateRegions: AppTools.User != null
                                                                                    ? new ItemInsertionUpdateRegion(
                            createUpdateRegions.ToCollection(),
                            () => commentMod.CommentId.ToString().ToCollection()).ToCollection()
                                                                                    : null)));

            return(components);
        }
 protected override PageContent getContent() =>
 new UiPageContent(
     pageActions: AppTools.User != null && articleRow.AuthorId == AppTools.User.UserId
                                                      ? new HyperlinkSetup(
         Editor.GetInfo(ArticleId),
         "Edit Article",
         icon: new ActionComponentIcon(new FontAwesomeIcon("fa-pencil")))
     .Append <ActionComponentSetup>(
         new ButtonSetup(
             "Delete Article",
             behavior: new PostBackBehavior(
                 postBack: PostBack.CreateFull(
                     id: "delete",
                     modificationMethod: () => {
     ArticleTagsModification.DeleteRows(new ArticleTagsTableEqualityConditions.ArticleId(ArticleId));
     ArticlesModification.DeleteRows(new ArticlesTableEqualityConditions.ArticleId(ArticleId));
 },
                     actionGetter: () => new PostBackAction(Home.GetInfo()))),
             icon: new ActionComponentIcon(new FontAwesomeIcon("fa-trash"))))
     .Materialize()
                                                      : AppStatics.GetFollowAction(articleRow.AuthorId).Append(getFavoriteAction()).Materialize())
 .Add(AppStatics.GetAuthorDisplay(articleRow, UsersTableRetrieval.GetRowMatchingId(articleRow.AuthorId)))
 .Add(new HtmlBlockContainer(Markdown.ToHtml(articleRow.BodyMarkdown)))
 .Add(AppStatics.GetTagDisplay(ArticleId, ArticleTagsTableRetrieval.GetRowsLinkedToArticle(ArticleId)))
 .Add(getCommentComponents());
예제 #3
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);
        }
예제 #4
0
        private UsersModification getMod()
        {
            if (AppTools.User != null)
            {
                return(UsersTableRetrieval.GetRowMatchingId(AppTools.User.UserId).ToModification());
            }

            var mod = UsersModification.CreateForInsert();

            mod.ProfilePictureUrl = "";
            mod.ShortBio          = "";
            return(mod);
        }
예제 #5
0
        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);
        }
예제 #6
0
        public override IReadOnlyCollection <ActionComponentSetup> GetGlobalNavActions()
        {
            if (AppTools.User == null)
            {
                var signUpPage = User.GetInfo();
                return(new[]
                {
                    new HyperlinkSetup(Home.GetInfo(), "Home"),
                    new HyperlinkSetup(EnterpriseWebLibrary.EnterpriseWebFramework.UserManagement.Pages.LogIn.GetInfo(Home.GetInfo().GetUrl()), "Sign in"),
                    new HyperlinkSetup(signUpPage, signUpPage.ResourceName)
                }.ToList());
            }

            return(new[]
            {
                new HyperlinkSetup(Home.GetInfo(), "Home"),
                new HyperlinkSetup(Editor.GetInfo(null), "New Article", icon: new ActionComponentIcon(new FontAwesomeIcon("fa-pencil-square-o"))),
                new HyperlinkSetup(User.GetInfo(), "Settings", icon: new ActionComponentIcon(new FontAwesomeIcon("fa-cog"))),
                new HyperlinkSetup(Profile.GetInfo(AppTools.User.UserId), UsersTableRetrieval.GetRowMatchingId(AppTools.User.UserId).Username)
            }.ToList());
        }
예제 #7
0
        internal static ActionComponentSetup GetFollowAction(int userId)
        {
            var text = "{0} {1} ({2})".FormatWith(
                AppTools.User == null || FollowsTableRetrieval.GetRowMatchingPk(AppTools.User.UserId, userId, returnNullIfNoMatch: true) == null
                                        ? "Follow"
                                        : "Unfollow",
                UsersTableRetrieval.GetRowMatchingId(userId).Username,
                FollowsTableRetrieval.GetRows(new FollowsTableEqualityConditions.FolloweeId(userId)).Count());
            var icon = new ActionComponentIcon(new FontAwesomeIcon("fa-plus"));

            return(AppTools.User == null
                                       ? (ActionComponentSetup) new HyperlinkSetup(User.GetInfo(), text, icon: icon)
                                       : new ButtonSetup(
                       text,
                       behavior: new PostBackBehavior(
                           postBack: FollowsTableRetrieval.GetRowMatchingPk(AppTools.User.UserId, userId, returnNullIfNoMatch: true) == null
                                                                         ? PostBack.CreateFull(id: "follow", modificationMethod: () => FollowsModification.InsertRow(AppTools.User.UserId, userId))
                                                                         : PostBack.CreateFull(
                               id: "unfollow",
                               modificationMethod: () => FollowsModification.DeleteRows(
                                   new FollowsTableEqualityConditions.FollowerId(AppTools.User.UserId),
                                   new FollowsTableEqualityConditions.FolloweeId(userId)))),
                       icon: icon));
        }
예제 #8
0
 FormsAuthCapableUser FormsAuthCapableUserManagementProvider.GetUser(string email) =>
 getUserObject(UsersTableRetrieval.GetRows(new UsersTableEqualityConditions.EmailAddress(email)).SingleOrDefault());
예제 #9
0
 FormsAuthCapableUser FormsAuthCapableUserManagementProvider.GetUser(int userId) =>
 getUserObject(UsersTableRetrieval.GetRowMatchingId(userId, returnNullIfNoMatch: true));
예제 #10
0
 IEnumerable <FormsAuthCapableUser> FormsAuthCapableUserManagementProvider.GetUsers() =>
 UsersTableRetrieval.GetRows().OrderBy(i => i.Username).Select(getUserObject);
예제 #11
0
 protected override void init()
 {
     user = UsersTableRetrieval.GetRowMatchingId(UserId);
 }