Esempio 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));
        }
Esempio 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));
 }
Esempio 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));
 }
Esempio 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));
 }
Esempio n. 6
0
 public IQueryable <BookGenre> GetBookGenre([ScopedService] GlobalAzureContext context)
 {
     return(context.BookGenres);
 }
Esempio n. 7
0
 public IQueryable <InventoryMovement> GetInventoryMovements([ScopedService] GlobalAzureContext context)
 {
     return(context.InventoryMovements);
 }
Esempio n. 8
0
 public IQueryable <Inventory> GetInventory([ScopedService] GlobalAzureContext context)
 {
     return(context.Inventories);
 }