Exemplo n.º 1
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));
        }
Exemplo n.º 2
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));
            }
        }