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)); }
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(); }
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(); } }