private async Task <Comment> AddPaymentCommentAsync( CommentDiscussion discussion, PaymentType paymentType, ClaimPaymentRequest request) { Comment comment = CommentHelper.CreateCommentForDiscussion( discussion, CurrentUserId, Now, request.CommentText ?? "", true, null); comment.Finance = new FinanceOperation { OperationType = FinanceOperationType.Online, PaymentTypeId = paymentType.PaymentTypeId, MoneyAmount = request.Money, OperationDate = request.OperationDate, ProjectId = request.ProjectId, ClaimId = request.ClaimId, Created = Now, Changed = Now, State = FinanceOperationState.Proposed, }; UnitOfWork.GetDbSet <Comment>().Add(comment); await UnitOfWork.SaveChangesAsync(); return(comment); }
private async Task <ForumEmail> AddCommentWithEmail(string commentText, ForumThread forumThread, bool isVisibleToPlayer, Comment parentComment) { var visibleToPlayerUpdated = isVisibleToPlayer && parentComment?.IsVisibleToPlayer != false; CommentHelper.CreateCommentForDiscussion(forumThread.CommentDiscussion, CurrentUserId, Now, commentText, isVisibleToPlayer, parentComment); var extraRecipients = new[] { parentComment?.Author, parentComment?.Finance?.PaymentType?.User }; var subscriptions = forumThread.GetSubscriptions(extraRecipients, visibleToPlayerUpdated).ToList(); return(new ForumEmail() { ForumThread = forumThread, ProjectName = forumThread.Project.ProjectName, Initiator = await UserRepository.GetById(CurrentUserId), Recipients = subscriptions.ToList(), Text = new MarkdownString(commentText), }); }
private async Task <Tuple <Comment, Comment> > AddTransferCommentsAsync( Claim claimFrom, Claim claimTo, ClaimPaymentTransferRequest request) { // Comment to source claim Comment commentFrom = CommentHelper.CreateCommentForDiscussion( claimFrom.CommentDiscussion, CurrentUserId, Now, request.CommentText, true, null); commentFrom.Finance = new FinanceOperation { OperationType = FinanceOperationType.TransferTo, MoneyAmount = -request.Money, OperationDate = request.OperationDate, ProjectId = request.ProjectId, ClaimId = request.ClaimId, LinkedClaimId = request.ToClaimId, Created = Now, Changed = Now, State = FinanceOperationState.Approved, }; UnitOfWork.GetDbSet <Comment>().Add(commentFrom); // Comment to destination claim Comment commentTo = CommentHelper.CreateCommentForDiscussion( claimTo.CommentDiscussion, CurrentUserId, Now, request.CommentText, true, null); commentTo.Finance = new FinanceOperation { OperationType = FinanceOperationType.TransferFrom, MoneyAmount = request.Money, OperationDate = request.OperationDate, ProjectId = request.ProjectId, ClaimId = request.ToClaimId, LinkedClaimId = request.ClaimId, Created = Now, Changed = Now, State = FinanceOperationState.Approved, }; await UnitOfWork.SaveChangesAsync(); return(Tuple.Create(commentFrom, commentTo)); }
public async Task <int> CreateThread(int projectId, int characterGroupId, string header, string commentText, bool hideFromUser, bool emailEverybody) { var group = await LoadProjectSubEntityAsync <CharacterGroup>(projectId, characterGroupId); group.RequestMasterAccess(CurrentUserId); var forumThread = new ForumThread() { CharacterGroupId = characterGroupId, ProjectId = projectId, Header = Required(header), CreatedAt = Now, ModifiedAt = Now, AuthorUserId = CurrentUserId, IsVisibleToPlayer = !hideFromUser, CommentDiscussion = new CommentDiscussion() { ProjectId = projectId }, }; CommentHelper.CreateCommentForDiscussion(forumThread.CommentDiscussion, CurrentUserId, Now, commentText, !hideFromUser, parentComment: null); group.ForumThreads.Add(forumThread); await UnitOfWork.SaveChangesAsync(); if (emailEverybody) { var groups = GetChildrenGroupIds(group); var players = hideFromUser ? new User[] {} : (await ClaimsRepository.GetClaimsForGroups(projectId, ClaimStatusSpec.Approved, groups)).Select( claim => claim.Player); var masters = forumThread.Project.ProjectAcls.Select(acl => acl.User); var fe = new ForumEmail() { ForumThread = forumThread, ProjectName = forumThread.Project.ProjectName, Initiator = await UserRepository.GetById(CurrentUserId), Recipients = players.Union(masters).ToList(), Text = new MarkdownString(commentText), }; await EmailService.Email(fe); } return(forumThread.ForumThreadId); }
protected Comment AddCommentImpl(Claim claim, Comment parentComment, string commentText, bool isVisibleToPlayer, CommentExtraAction?extraAction = null) { var comment = CommentHelper.CreateCommentForDiscussion(claim.CommentDiscussion, CurrentUserId, Now, commentText, isVisibleToPlayer, parentComment, extraAction); claim.LastUpdateDateTime = Now; return(comment); }