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