Ejemplo n.º 1
0
        public async Task <ActionResult> RedirectToDiscussion(int projectid,
                                                              int?commentid,
                                                              int?commentDiscussionId)
        {
            CommentDiscussion discussion;

            if (commentid != null)
            {
                discussion = await ForumRepository.GetDiscussionByComment(projectid, (int)commentid);
            }
            else if (commentDiscussionId != null)
            {
                discussion =
                    await ForumRepository.GetDiscussion(projectid, (int)commentDiscussionId);
            }
            else
            {
                return(HttpNotFound());
            }

            if (!discussion.HasAnyAccess(CurrentUserId))
            {
                return(NoAccesToProjectView(discussion.Project));
            }

            return(ReturnToParent(discussion, commentid != null ? $"comment{commentid}" : null));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> ConcealComment(int projectid, int commentid, int commentDiscussionId)
        {
            await ClaimService.ConcealComment(projectid, commentid, commentDiscussionId, CurrentUserId);

            var discussion =
                await ForumRepository.GetDiscussion(projectid, commentDiscussionId);

            return(CommentRedirectHelper.RedirectToDiscussion(Url, discussion));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> CreateComment(AddCommentViewModel viewModel)
        {
            CommentDiscussion discussion = await ForumRepository.GetDiscussion(viewModel.ProjectId, viewModel.CommentDiscussionId);

            discussion.RequestAnyAccess(CurrentUserId);

            if (discussion == null)
            {
                return(NotFound());
            }

            try

            {
                if (viewModel.HideFromUser)
                {
                    _ = discussion.RequestMasterAccess(CurrentUserId);
                }

                var claim = discussion.GetClaim();
                if (claim != null)
                {
                    await ClaimService.AddComment(discussion.ProjectId,
                                                  claim.ClaimId,
                                                  viewModel.ParentCommentId,
                                                  !viewModel.HideFromUser,
                                                  viewModel.CommentText,
                                                  (FinanceOperationAction)viewModel.FinanceAction);
                }
                else
                {
                    var forumThread = discussion.GetForumThread();
                    if (forumThread != null)
                    {
                        await ForumService.AddComment(discussion.ProjectId, forumThread.ForumThreadId, viewModel.ParentCommentId,
                                                      !viewModel.HideFromUser, viewModel.CommentText);
                    }
                }

                return(CommentRedirectHelper.RedirectToDiscussion(Url, discussion));
            }
            catch
            {
                //TODO: Message that comment is not added
                return(CommentRedirectHelper.RedirectToDiscussion(Url, discussion));
            }
        }