public async Task <Book> AddBook(AddBookInput book, [Service] IEventSender eventSender) { var newBook = _bookService.Add(book); await eventSender.SendAsync(new OnBookAddedMessage(newBook)); return(newBook); }
public async Task <GetBookOutput> Add(AddBookInput input) { // 以下为工作单元多种适用场景 new Thread(() => { Thread.Sleep(10000); try { var books = _bookRepository.GetListAsync(m => m.Name.Contains("test")).Result; } catch (Exception ex) { throw ex; } }).Start(); using (var uow = _unitOfWorkManager.Begin()) { var book = input.MapTo <Book>(); book = await _bookRepository.InsertAsync(book); var bookQuery1 = await _bookRepository.QueryAsync <Book, Guid, Book>("select * from Books"); var a1 = bookQuery1.Take(10).ToList(); var a2 = bookQuery1.Take(10).ToList(); var bookQuery2 = await _bookRepository.QueryAsync <Book, Guid, Book>("select * from Books"); var b1 = bookQuery2.Take(10).ToList(); uow.Complete(); return(book.MapTo <GetBookOutput>()); } }
/// <inheritdoc /> public async Task <GetBookOutput> Add(AddBookInput input) { var book = input.MapTo <Book>(); book = await _bookRepository.InsertAsync(book); return(book.MapTo <GetBookOutput>()); }
public async Task <IActionResult> AddBook([FromBody] AddBookRequest message) { var request = new AddBookInput(message.BookId, message.BasketId); await addBookInput.Process(request); return(addBookPresenter.ViewModel); }
public Book Add(AddBookInput book) { var newBook = new Book { Id = Guid.NewGuid().ToString(), Title = book.Title }; _books.Add(newBook); return(newBook); }
public async Task <int> AddBookAsync(AddBookInput input) { var model = input.MapTo <Book>(); model.TenantId = _abpSession.TenantId; var id = await _bookResRepository.InsertAndGetIdAsync(model); return(id); }
public async Task <GetBookOutput> Add(AddBookInput input) { using (var uow = _unitOfWorkManager.Begin()) { var book = input.MapTo <Book>(); book = await _bookRepository.InsertAsync(book); uow.Complete(); return(book.MapTo <GetBookOutput>()); } }
public async Task <AddBookPayload> AddBookAsync( AddBookInput input, CancellationToken cancellationToken) { var book = new Book { Title = input.Title, AuthorId = input.AuthorId }; _bookContext.Books.Add(book); await _bookContext.SaveChangesAsync(cancellationToken); return(new AddBookPayload(book)); }
public async Task <AddBookPayload> AddBookAsync( AddBookInput input, [ScopedService] BookContext dbContext) { var book = new Book { Title = input.Title, AuthorId = input.AuthorId }; dbContext.Books.Add(book); await dbContext.SaveChangesAsync(); return(new AddBookPayload(book)); }
public async Task <AddBookPayload> AddBookAsync( AddBookInput input, [Service] ITopicEventSender eventSender, CancellationToken cancellationToken) { var book = new Book { Title = input.Title, AuthorId = input.AuthorId }; _bookContext.Books.Add(book); await _bookContext.SaveChangesAsync(cancellationToken); await eventSender.SendAsync(nameof(Subscription.OnBookReleased), book, cancellationToken); return(new AddBookPayload(book)); }
public async Task AddBook(AddBookInput input) { try { var book = new PX.Domain.Entities.Book { Id = new Guid(), Name = input.Name, NumberOfPages = input.NumberOfPages, DateOfPublication = input.DateOfPublication, Authors = input.Authors }; await _bookRepo.Create(book); } catch (Exception ex) { throw ex; } }
public async Task <Payload <Book> > AddBookAsync( AddBookInput input, [Service] IGetClaimsProvider claimsProvider, [ScopedService] BookRefDbContext context) { var book = new Book(input.Identifier, input.Title, claimsProvider.Username) { Subtitle = input.Subtitle }; var validationResult = new BookValidator().Validate(book); if (!validationResult.IsValid) { return(new Payload <Book>(BuildErrorList(validationResult.Errors))); } context.Books.Add(book); await context.SaveChangesAsync(); return(new Payload <Book>(book)); }
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)); }
public async Task <GetBookOutput> Post([FromBody] AddBookInput input) { return(await _bookService.Add(input)); }
public async Task Post([FromBody] AddBookInput request) { await _bookService.AddBook(request); }
public async Task <int> AddBookAsync(AddBookInput input) { var result = await _bookService.AddBookAsync(input); return(result); }