Ejemplo n.º 1
0
        public async Task <AddBookPayload> AddBookAsync(
            AddBookInput input,
            [ScopedService] GlobalAzureContext context,
            [Service] ITopicEventSender eventSender,
            CancellationToken cancellationToken
            )
        {
            var book = new Book
            {
                Title       = input.book.Title,
                Category    = input.book.Category,
                Price       = input.book.Price,
                Isbn        = input.book.Isbn,
                PublishDate = input.book.PublishDate,
                CreatedAt   = System.DateTime.Now
            };

            context.Books.Add(book);
            await context.SaveChangesAsync(cancellationToken);

            await eventSender.SendAsync(nameof(Subscription.OnBookAdded), book, cancellationToken);

            return(new AddBookPayload(book));
        }
Ejemplo n.º 2
0
 public IQueryable <Author> GetBookAuthors(Book book, [ScopedService] GlobalAzureContext context)
 {
     return(context.BookAuthors.Where(p => p.BookId == book.Id).Select(n => n.Author));
 }
Ejemplo n.º 3
0
 public IQueryable <Genre> GetGenre(Genre genre, [ScopedService] GlobalAzureContext context)
 {
     return(context.BookGenres.Where(p => p.GenreId == genre.Id).Select(n => n.Genre));
 }
 public IQueryable <Book> GetInventoryBooks(Inventory inventory, [ScopedService] GlobalAzureContext context)
 {
     return(context.Inventories.Where(i => i.Id == inventory.Id).Select(n => n.Book));
 }
Ejemplo n.º 5
0
 public IQueryable <Inventory> GetInventoriesMovements(Inventory inventory, [ScopedService] GlobalAzureContext context)
 {
     return(context.InventoryMovements.Where(i => i.InventoryId == inventory.Id).Select(n => n.Inventory));
 }
Ejemplo n.º 6
0
 public IQueryable <BookGenre> GetBookGenre([ScopedService] GlobalAzureContext context)
 {
     return(context.BookGenres);
 }
Ejemplo n.º 7
0
 public IQueryable <InventoryMovement> GetInventoryMovements([ScopedService] GlobalAzureContext context)
 {
     return(context.InventoryMovements);
 }
Ejemplo n.º 8
0
 public IQueryable <Inventory> GetInventory([ScopedService] GlobalAzureContext context)
 {
     return(context.Inventories);
 }