public async Task <GetBookOutput> Create(CreateBookInput 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 = _mapper.Map <Book>(input); 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(_mapper.Map <GetBookOutput>(book)); } }
/// <inheritdoc /> public async Task <GetBookOutput> Create(CreateBookInput input) { var book = _mapper.Map <Book>(input); book = await _bookRepository.InsertAsync(book); return(_mapper.Map <GetBookOutput>(book)); }
public async Task <ActionResult> Create(CreateBookInput input) { try { await _bookService.CreateAsync(input); return(Ok()); } catch (Exception ex) { return(NotFound(ex)); } }
public async Task CreateAsync(CreateBookInput input) { try { Book newBook = Book.Create(input.Name, input.Price, input.ImgUrl, input.Rating, input.Binding, input.ReleaseDate, input.Details, input.PublisherId, input.AuthorId); await _context.Books.AddAsync(newBook); await _context.SaveChangesAsync(); } catch (Exception err) { throw err; } }
public Book Create(CreateBookInput inputBook) { var newBook = new Book() { Id = _books.Max(x => x.Id) + 1, Title = inputBook.Title, Price = inputBook.Price, AuthorId = inputBook.AuthorId, }; _books.Add(newBook); return(newBook); }
public async Task <IActionResult> Put([FromBody] CreateBookRequest message) { var request = new CreateBookInput { BookName = message.BookName, Author = message.Author, Isbn = message.Isbn, Price = message.Price, }; await createBookInput.Process(request); return(createBookPresenter.ViewModel); }
public async Task <ActionResult> BookShip(CreateBookInput input) { Book order = new Book { BookNo = input.BookNo, Author = input.Author, BookName = input.BookName, Category = input.Category, Price = input.Price }; await _bookRepository.AddAsync(order); return(Ok()); }
public void CreateBook(CreateBookInput input) { try { var book = new Book { Title = input.Title, Summary = input.Summary, Year = input.Year, ISBN = input.ISBN, UserId = AbpSession.UserId, AuthorName = input.AuthorName, ImageLink = input.ImageLink, Rating = 0 }; _bookRepository.Insert(book); Logger.Info("Inserted book with title: " + book.Title); } catch (Exception e) { Logger.Info("Exception in CreateBook: " + e); } }
public async Task Create(CreateBookInput input) { var book = _mapper.Map <Book>(input); await _bookManager.Create(book); }
public async Task Create(CreateBookInput input) { Book output = ObjectMapper.Map <Book>(input); await _bookManager.Create(output); }
public async Task <GetBookOutput> Post([FromBody] CreateBookInput input) { return(await _bookService.Create(input)); }
public async Task Create(CreateBookInput input) { var book = ObjectMapper.Map <Book>(input); await _bookRepository.InsertAsync(book); }
public async Task <IActionResult> Save(CreateBookInput command) { await _createBookUseCase.Execute(command); return(Ok()); }