コード例 #1
0
 public async Task <EditorInteractionComment> GetComment(GetOrDeleteCommentInput input, Guid interactionId)
 {
     return(await Repository
            .WhereIf(input.ObjectId != null, c => c.ObjectId == input.ObjectId)
            .WhereIf(input.ObjectTypeEnum != null, c => c.ObjectTypeEnum == input.ObjectTypeEnum)
            .FirstOrDefaultAsync(c => c.InteractionId == interactionId));
 }
コード例 #2
0
        public async Task RemoveComment(GetOrDeleteCommentInput input, Guid interactionId)
        {
            var comment = await GetComment(input, interactionId);

            if (comment == null)
            {
                return;
            }

            var subComments = await FindSubChildren(comment.Id);

            Repository.RemoveRange(subComments);
            Repository.Remove(comment);
            await Context.SaveChangesAsync();
        }
コード例 #3
0
        public async Task UpdateComment([FromBody] UpdateCommentInput input, Guid interactionId)
        {
            var getInput = new GetOrDeleteCommentInput
            {
                ObjectId       = input.ObjectId,
                ObjectTypeEnum = input.ObjectTypeEnum
            };
            var comment = await GetComment(getInput, interactionId);

            if (comment != null)
            {
                comment.Message = input.Message;
                Repository.Update(comment);
                await Context.SaveChangesAsync();
            }
        }