Пример #1
0
        public async Task <Author> Handle(GetAuthorByIdQuery request, CancellationToken cancellationToken)
        {
            string functionName = "GetAuthorById:Get:" + request.Id;

            Log.ForContext("Message", functionName)
            .ForContext("Error", "").Information(functionName);

            var author = await _read.GetAuthorById(request.Id);

            return(author is null ? null : author);
        }
        public async Task <ResultStatus> Handle(RemoveAuthorCommand request, CancellationToken cancellationToken)
        {
            var author = await _read.GetAuthorById(request.Id);

            if (author == null)
            {
                Log.ForContext("Message", "RemoveAuthor:Get:" + request.Id)
                .ForContext("Error", "UserNotFound")
                .Error($"Error: ** RemoveAuthor: Get: {request.Id}");
                return(ResultStatus.NotFound);
            }



            await _write.RemoveAuthor(author);

            await _write.Save();

            return(ResultStatus.Success);
        }
        public async Task <Author> Handle(GetAuthorByIdQuery request, CancellationToken cancellationToken)
        {
            Log.Information("GetAuthorById" + request.Id);

            return(await _query.GetAuthorById(request.Id));
        }