public async Task <ResultStatus> Handle(AddCommentCommand request, CancellationToken cancellationToken) { Comment comment = new Comment() { PostId = long.Parse(request.PostId), Text = request.Text }; await _write.AddComment(comment); await _write.Save(); return(ResultStatus.Success); }
public async Task <ResultStatus> Handle(RemoveCommentCommand request, CancellationToken cancellationToken) { string functionName = "RemoveComment:Get:" + request.Id; Log.ForContext("Message", functionName) .ForContext("Error", "") .Information(functionName); var comment = await _read.GetCommentById(request.Id); if (comment == null) { Log.ForContext("Message", functionName) .ForContext("Error", "CommentNotFound") .Error($"Error: ** {functionName}"); return(ResultStatus.NotFound); } await _write.RemoveComment(comment); await _write.Save(); return(ResultStatus.Success); }