예제 #1
0
        public IActionResult DeletePost(int threadID)
        {
            forumThread = forumThreadCollection.GetForumThread(threadID);
            forumThread.DeleteForumThread();

            return(RedirectToAction("Index"));
        }
예제 #2
0
 public static bool HasAnyAccess([NotNull] this IForumThread forumThread, int?currentUserId)
 {
     if (forumThread == null)
     {
         throw new ArgumentNullException(nameof(forumThread));
     }
     return(forumThread.HasMasterAccess(currentUserId) || forumThread.HasPlayerAccess(currentUserId));
 }
예제 #3
0
 public static bool HasPlayerAccess([NotNull] this IForumThread forumThread, int?currentUserId)
 {
     if (forumThread == null)
     {
         throw new ArgumentNullException(nameof(forumThread));
     }
     return(currentUserId != null && forumThread.IsVisibleToPlayer &&
            forumThread.Project.Claims.OfUserApproved((int)currentUserId)
            .Any(c => c.IsPartOfGroup(forumThread.CharacterGroupId)));
 }
예제 #4
0
        public IActionResult Edit(int threadID)
        {
            forumThread = forumThreadCollection.GetForumThread(threadID);
            EditThreadViewModel model = new EditThreadViewModel()
            {
                ThreadID      = forumThread.ThreadID,
                ThreadMessage = forumThread.ThreadMessage
            };

            return(View(model));
        }
예제 #5
0
 public ForumController()
 {
     forumCategory           = LogicFactory.LogicFactory.GetForumCategory();
     forumCategoryCollection = LogicFactory.LogicFactory.GetForumCategoryCollection();
     forumThread             = LogicFactory.LogicFactory.GetForumThread();
     forumThreadCollection   = LogicFactory.LogicFactory.GetForumThreadCollection();
     forumPost           = LogicFactory.LogicFactory.GetForumPost();
     forumPostCollection = LogicFactory.LogicFactory.GetForumPostCollection();
     account             = LogicFactory.LogicFactory.GetAccount();
     accountCollection   = LogicFactory.LogicFactory.GetAccountCollection();
 }
예제 #6
0
        public IActionResult Delete(int threadID)
        {
            forumThread = forumThreadCollection.GetForumThread(threadID);

            DeleteThreadViewModel model = new DeleteThreadViewModel()
            {
                ForumThread   = forumThread,
                ForumCategory = forumCategoryCollection.GetForumCategory(forumThread.ForumCategoryID)
            };

            return(View(model));
        }
예제 #7
0
        public int CreateForumThread(IForumThread forumThread)
        {
            IForumThreadDto forumThreadDto = new ForumThreadDto()
            {
                AccountID         = forumThread.AccountID,
                ForumCategoryID   = forumThread.ForumCategoryID,
                ThreadTitle       = forumThread.ThreadTitle,
                ThreadMessage     = forumThread.ThreadMessage,
                ThreadDateCreated = forumThread.ThreadDateCreated,
            };

            int rowcount = db.CreateThread(forumThreadDto);

            return(rowcount);
        }
예제 #8
0
        public IActionResult ThreadPage(int threadID)
        {
            forumThread = forumThreadCollection.GetForumThread(threadID);
            account     = accountCollection.GetAccount(forumThread.AccountID);
            List <IForumPost> forumPosts = forumPostCollection.GetForumPosts(threadID);

            ForumThreadViewModel model = new ForumThreadViewModel()
            {
                ThreadID          = forumThread.ThreadID,
                ThreadCreator     = account,
                ThreadTitle       = forumThread.ThreadTitle,
                ThreadMessage     = forumThread.ThreadMessage,
                ThreadDateCreated = forumThread.ThreadDateCreated,
                Posts             = forumPosts
            };

            return(View(model));
        }
        public string GetLatestPostUrl(IForumThread forumThread, int forumThreadPostCount)
        {
            if (forumThread == null)
            {
                return(null);
            }

            var latestPost = forumThread.LatestPost;

            if (latestPost == null || latestPost.EntityReference == null)
            {
                return(forumThread.Url);
            }

            var latestPostId = latestPost.EntityReference.Id;

            return(GetPostUrl(forumThread, latestPostId));
        }
예제 #10
0
        public ForumThreadDrop(IPortalLiquidContext portalLiquidContext, IDataAdapterDependencies dependencies, IForumThread thread)
            : base(portalLiquidContext, thread)
        {
            if (dependencies == null)
            {
                throw new ArgumentNullException("dependencies");
            }

            _dependencies = dependencies;

            Thread = thread;
            Author = thread.Author != null ? new AuthorDrop(portalLiquidContext, Thread.Author) : null;

            _adapter = new ForumThreadDataAdapter(thread.EntityReference, dependencies);

            _firstPost  = new Lazy <ForumPostDrop>(() => new ForumPostDrop(this, _dependencies, _adapter.SelectFirstPost()), LazyThreadSafetyMode.None);
            _latestPost = new Lazy <ForumPostDrop>(() => new ForumPostDrop(this, _dependencies, _adapter.SelectLatestPost()), LazyThreadSafetyMode.None);
        }
        public ForumPostsDrop(IPortalLiquidContext portalLiquidContext,
                              IDataAdapterDependencies dependencies,
                              IForumThread forumThread,
                              int startRowIndex = 0, int pageSize = -1) : base(portalLiquidContext)
        {
            Dependencies = dependencies;

            PortalLiquidContext = portalLiquidContext;

            SetParams(startRowIndex, pageSize);

            ForumThread = forumThread;

            var forumAggregationDataAdapter = new ForumThreadDataAdapter(forumThread.Entity.ToEntityReference(), Dependencies);

            _adapter = forumAggregationDataAdapter;

            _posts = new Lazy <ForumPostDrop[]>(() => _adapter.SelectPosts(StartRowIndex, PageSize).Select(e => new ForumPostDrop(this, Dependencies, e)).ToArray(), LazyThreadSafetyMode.None);
        }
        public string GetPostUrl(IForumThread forumThread, int forumThreadPostCount, Guid forumPostId)
        {
            string forumThreadUrl = forumThread.Url;

            if (forumThreadUrl == null)
            {
                return(null);
            }

            if (forumThreadPostCount < 1)
            {
                return("{0}#{1}".FormatWith(forumThread.Url, _anchorFormat.FormatWith(forumPostId)));
            }

            var pageNumber = ((forumThreadPostCount - 1) / _pageSize) + 1;

            return("{0}#{1}".FormatWith(
                       forumThread.Url.AppendQueryString(_pageQueryStringField, pageNumber.ToString(CultureInfo.InvariantCulture)),
                       _anchorFormat.FormatWith(forumPostId)));
        }
        public IForumThread CreateThread(IForumThread forumThread, IForumPostSubmission forumPost)
        {
            if (forumThread == null)
            {
                throw new ArgumentNullException("forumThread");
            }

            ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Forum={0}: Start", Forum.Id));

            var serviceContext = Dependencies.GetServiceContextForWrite();

            var entity = new Entity("adx_communityforumthread");

            entity["adx_forumid"]      = Forum;
            entity["adx_name"]         = Truncate(forumThread.Name, 100);
            entity["adx_sticky"]       = forumThread.IsSticky;
            entity["adx_isanswered"]   = forumThread.IsAnswered;
            entity["adx_locked"]       = forumThread.Locked;
            entity["adx_typeid"]       = forumThread.ThreadType.EntityReference;
            entity["adx_lastpostdate"] = forumPost.PostedOn;

            serviceContext.AddObject(entity);
            serviceContext.SaveChanges();

            var threadDataAdapter = new ForumThreadDataAdapter(entity.ToEntityReference(), Dependencies);

            threadDataAdapter.CreatePost(forumPost, true);

            var createdThread = threadDataAdapter.Select();

            ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Forum={0}: End", Forum.Id));

            if (FeatureCheckHelper.IsFeatureEnabled(FeatureNames.TelemetryFeatureUsage))
            {
                PortalFeatureTrace.TraceInstance.LogFeatureUsage(FeatureTraceCategory.Forum, HttpContext.Current, "create_forum_thread", 1, entity.ToEntityReference(), "create");
            }

            return(createdThread);
        }
예제 #14
0
        public ForumPost(Entity entity, IPortalViewEntity viewEntity, IForumPostInfo postInfo,
                         Lazy <ApplicationPath> getEditPath = null, Lazy <ApplicationPath> getDeletePath = null,
                         Lazy <bool> editable = null, Lazy <bool> canMarkAsAnswer = null, string url = null, IForumThread thread = null,
                         Lazy <bool> canEdit  = null)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }
            if (viewEntity == null)
            {
                throw new ArgumentNullException("viewEntity");
            }
            if (postInfo == null)
            {
                throw new ArgumentNullException("postInfo");
            }

            Entity           = entity;
            _viewEntity      = viewEntity;
            _editable        = editable;
            AttachmentInfo   = postInfo.AttachmentInfo ?? new IForumPostAttachmentInfo[] { };
            Author           = postInfo.Author;
            _getEditPath     = getEditPath ?? new Lazy <ApplicationPath>(() => null, LazyThreadSafetyMode.None);
            _getDeletePath   = getDeletePath ?? new Lazy <ApplicationPath>(() => null, LazyThreadSafetyMode.None);
            _canMarkAsAnswer = canMarkAsAnswer ?? new Lazy <bool>(() => false, LazyThreadSafetyMode.None);
            _canEdit         = canEdit ?? new Lazy <bool>(() => false, LazyThreadSafetyMode.None);
            _url             = url;
            Thread           = thread;

            Content          = entity.GetAttributeValue <string>("adx_content");
            IsAnswer         = entity.GetAttributeValue <bool?>("adx_isanswer").GetValueOrDefault();
            HelpfulVoteCount = entity.GetAttributeValue <int?>("adx_helpfulvotecount").GetValueOrDefault();
            Name             = entity.GetAttributeValue <string>("adx_name");
            PostedOn         = entity.GetAttributeValue <DateTime?>("adx_date").GetValueOrDefault(postInfo.PostedOn);
        }
 public ForumThreadDataAdapter(IForumThread forumThread, IDataAdapterDependencies dependencies)
     : this(forumThread.EntityReference, dependencies)
 {
 }
 public string GetPostUrl(IForumThread forumThread, Guid forumPostId)
 {
     return("{0}#post-{1}".FormatWith(forumThread.Url, forumPostId));
 }