protected override async Task OnParametersSetAsync()
        {
            var node = await NodeService.GetBySlugAsync(
                Constants.ForumsModule,
                Constants.ForumType,
                Slug);

            Forum = Models.Forum.Create(node);
            var createdBy = node.CreatedBy;

            Topics = new TopicsModel(NodeService)
            {
                NodeSearch = new NodeSearch()
                {
                    Module   = Constants.ForumsModule,
                    Type     = Constants.TopicType,
                    ParentId = node.Id,
                    OrderBy  = new string[]
                    {
                        OrderBy.Hot,
                        OrderBy.Latest
                    }
                }
            };
            await Topics.InitAsync();

            var loggedInUserId = (await AuthenticationStateTask).LoggedInUserId();

            CanEditForum = await SecurityService.AllowedAsync(
                loggedInUserId,
                createdBy,
                Constants.ForumsModule,
                Constants.ForumType,
                Actions.Edit
                );

            CanDeleteForum = await SecurityService.AllowedAsync(
                loggedInUserId,
                createdBy,
                Constants.ForumsModule,
                Constants.ForumType,
                Actions.Delete
                );

            CanAddTopic = await SecurityService.AllowedAsync(
                loggedInUserId,
                null,
                Constants.ForumsModule,
                Constants.TopicType,
                Actions.Add
                );
        }
예제 #2
0
        public IActionResult Topics(int?id)
        {
            TopicsModel model = new TopicsModel();

            model.Topics = topics.GetAllTopics();
            if (id.HasValue)
            {
                // retrieve articles
                model.ActiveTopic = topics.GetTopic(id.Value);
                // retrieve active topic info
                model.Articles = articles.GetByTopic(id.Value);
            }

            return(View(model));
        }
예제 #3
0
        // /topics
        public ActionResult List()
        {
            var topicsModel = new TopicsModel();

            foreach (var topic in _channels.SelectMany(x => x.Topics))
            {
                var current = topicsModel.Topics.SingleOrDefault(x => x.Id == topic.Id);
                if (current == null)
                {
                    current = new TopicModel();
                    topicsModel.Topics.Add(current);
                }

                current.Id    = topic.Id;
                current.Topic = topic.Topic;
                current.Videos.AddRange(topic.Videos);
            }

            return(View("List", topicsModel));
        }
예제 #4
0
        protected override async Task OnParametersSetAsync()
        {
            var node = await NodeService.GetBySlugAsync(
                Constants.ForumsModule,
                Constants.ForumType,
                Slug);

            Forum = Models.Forum.Create(node);
            var createdBy = node.CreatedBy;

            if (!string.IsNullOrEmpty(Forum.ParentId))
            {
                var parentNode = await NodeService.GetAsync(Forum.ParentId);

                if (parentNode != null)
                {
                    ParentForum = Models.Forum.Create(parentNode);
                }
            }
            else
            {
                ParentForum = null;
            }

            Forums = new ForumsModel(NodeService)
            {
                NodeSearch = new NodeSearch()
                {
                    Module   = Constants.ForumsModule,
                    Type     = Constants.ForumType,
                    OrderBy  = $"{OrderBy.Title}",
                    ParentId = node.Id
                }
            };
            await Forums.InitAsync();

            var loggedInUserId = (await AuthenticationStateTask).LoggedInUserId();

            CanAddForum = await SecurityService.AllowedAsync(
                loggedInUserId,
                null,
                Constants.ForumsModule,
                Constants.ForumType,
                Actions.Add
                );

            Topics = new TopicsModel(NodeService)
            {
                NodeSearch = new NodeSearch()
                {
                    Module          = Constants.ForumsModule,
                    Type            = Constants.TopicType,
                    ParentId        = node.Id,
                    OrderBy         = $"{OrderBy.Hot},{OrderBy.Latest}",
                    TruncateContent = 140
                }
            };
            await Topics.InitAsync();

            CanEditForum = await SecurityService.AllowedAsync(
                loggedInUserId,
                createdBy,
                Constants.ForumsModule,
                Constants.ForumType,
                Actions.Edit
                );

            CanDeleteForum = await SecurityService.AllowedAsync(
                loggedInUserId,
                createdBy,
                Constants.ForumsModule,
                Constants.ForumType,
                Actions.Delete
                );

            CanAddTopic = await SecurityService.AllowedAsync(
                loggedInUserId,
                null,
                Constants.ForumsModule,
                Constants.TopicType,
                Actions.Add
                );
        }