private ActionResult ReturnToParent(CommentDiscussion discussion, string extra = null) { if (extra == null) { extra = ""; } else { extra = "#" + extra; } var claim = discussion.GetClaim(); if (claim != null) { var actionLink = Url.Action("Edit", "Claim", new { claim.ClaimId, discussion.ProjectId }); return(Redirect(actionLink + extra)); } var forumThread = discussion.GetForumThread(); if (forumThread != null) { var actionLink = Url.Action("ViewThread", new { discussion.ProjectId, forumThread.ForumThreadId }); return(Redirect(actionLink + extra)); } return(HttpNotFound()); }
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)); } }
public static bool HasPlayerAccess(this CommentDiscussion commentDiscussion, int currentUserId) { var forumThread = commentDiscussion.GetForumThread(); var claim = commentDiscussion.GetClaim(); if (forumThread != null) { return(forumThread.HasPlayerAccess(currentUserId)); } if (claim != null) { return(claim.HasPlayerAccesToClaim(currentUserId)); } throw new InvalidOperationException(); }
public static ActionResult RedirectToDiscussion(IUrlHelper Url, CommentDiscussion discussion, int?commentId = null) { var extra = commentId != null ? $"#comment{commentId}" : null; var claim = discussion.GetClaim(); if (claim != null) { var actionLink = Url.Action("Edit", "Claim", new { claim.ClaimId, discussion.ProjectId }); return(new RedirectResult(actionLink + extra)); } var forumThread = discussion.GetForumThread(); if (forumThread != null) { var actionLink = Url.Action("ViewThread", new { discussion.ProjectId, forumThread.ForumThreadId }); return(new RedirectResult(actionLink + extra)); } return(new NotFoundResult()); }