示例#1
0
        private async Task <Publisher> GetOrCreatePublisherAsync(CreateBookCommand request, CancellationToken cancellationToken)
        {
            var publisher = request.PublisherName is not null
                ? await _publisherRepository.FindByNameAsync(request.PublisherName) ??
                            _publisherRepository.Add(new Publisher(request.PublisherName))
                : null;

            await _publisherRepository.UnitOfWork.SaveChangesAsync(cancellationToken);

            return(publisher);
        }
示例#2
0
        public async Task <Publisher> FindByNameAsync(string name)
        {
            _logger.LogInfoMethodStarted <Publisher>(PublisherRepositoryType, nameof(FindByNameAsync), new object[] { name });

            var result = await _publisherRepository.FindByNameAsync(name);

            if (result is null)
            {
                _logger.LogWarningNotFound <Publisher>(PublisherRepositoryType, nameof(FindByNameAsync), new object[] { name });
            }


            _logger.LogInfoMethodEnded(PublisherRepositoryType, nameof(FindByNameAsync), result);
            return(result);
        }