public CrayonApiClient(HttpClient httpClient) { _httpClient = httpClient; _jsonSerializerSettings = new JsonSerializerSettings { MissingMemberHandling = MissingMemberHandling.Ignore, NullValueHandling = NullValueHandling.Include, DefaultValueHandling = DefaultValueHandling.Include, Formatting = Formatting.Indented }; _assemblyVersion = typeof(CrayonApiClient).GetTypeInfo().Assembly.GetName().Version.ToString(); Addresses = new AddressResource(this); AgreementProducts = new AgreementProductResource(this); Agreements = new AgreementResource(this); BillingStatements = new BillingStatementResource(this); BlogItems = new BlogItemResource(this); Clients = new ClientResource(this); CustomerTenants = new CustomerTenantResource(this); InvoiceProfiles = new InvoiceProfileResource(this); Me = new MeResource(this); OrganizationAccess = new OrganizationAccessResource(this); Organizations = new OrganizationResource(this); Publishers = new PublisherResource(this); Programs = new ProgramResource(this); Regions = new RegionResource(this); Secrets = new SecretResource(this); Subscriptions = new SubscriptionResource(this); Tokens = new TokenResource(this); UsageRecords = new UsageRecordResource(this); Users = new UserResource(this); }
public async Task <ActionResult <PublisherResource> > GetPublishers(int id) { var publisherFromRepo = await _publisherRepository.Get(id); if (publisherFromRepo == null) { return(NotFound()); } var resource = new List <PublisherBookResource>(); foreach (var book in publisherFromRepo.Books) { resource.Add(new PublisherBookResource { Id = book.Id, Title = book.Title, Description = book.Description, IsAvailable = book.IsAvailable, //AuthorNames = book.Authors.Select(e => e.FullName).ToList() }); } var publisherResource = new PublisherResource { Id = publisherFromRepo.Id, Name = publisherFromRepo.Name, Books = resource }; return(Ok(publisherResource)); }
public static List <PublisherResource> PublisherBookResource(this IEnumerable <Publisher> entity) { var listOfPublisherResource = new List <PublisherResource>(); foreach (var publisher in entity) { var publisherResource = new PublisherResource { Id = publisher.Id, Name = publisher.Name, Books = new List <PublisherBookResource>(), }; foreach (var book in publisher.Books) { var bookPublisher = new PublisherBookResource { Id = book.Id, Title = book.Title, Description = book.Description, IsAvailable = book.IsAvailable, AuthorNames = new List <AuthorCreateResource>(), }; foreach (var author in book.Authors) { bookPublisher.AuthorNames.Add(new AuthorCreateResource { Id = author.Id, FullName = author.FullName }); } publisherResource.Books.Add(bookPublisher); } listOfPublisherResource.Add(publisherResource); } return(listOfPublisherResource); }