コード例 #1
0
        public PublishierResponseDTO Get(Guid id)
        {
            var entity = _repository.Get(id)
                         .AsNoTracking()
                         .SingleOrDefault() ?? throw new EntityNotFoundException($"Publishier ({id})");

            var response = Mapper.Map <PublishierResponseDTO>(entity);

            return(response);
        }
コード例 #2
0
        public void PublishBook(Guid?id, PublishBookRequestDTO publishBookRequest)
        {
            var bookAsync = _repository.Get(id.GetValueOrDefault())
                            .Include(x => x.AuthorsBook)
                            .ThenInclude(x => x.Author)
                            .ThenInclude(x => x.Publishier)
                            .SingleOrDefaultAsync();

            var publisherAsync = _publishierRepository.Get(publishBookRequest.PublishierId.GetValueOrDefault())
                                 .SingleOrDefaultAsync();

            var book      = bookAsync.Result ?? throw new EntityNotFoundException($"Book ({id})");
            var publisher = publisherAsync.Result ?? throw new EntityNotFoundException($"Publishier ({publishBookRequest.PublishierId})");

            _publishBookBll.Publish(book, publisher);
        }