public async Task <IActionResult> AddBookCommand([FromBody] AddBookCommand command) { _logger.LogInformation("Adding book {0}", command.Name); await _mediator.DispatchAsync(command); _logger.LogInformation("Book {0} successfully added", command.Name); return(Ok()); }
public async Task <IEnumerable> SearchPhoneBookAsync(Guid phoneBookId, string name) { var query = new SearchPhoneBookQuery { PhoneBookId = phoneBookId, Name = name }; var result = await _mediator.DispatchAsync(query); return(result); }
public async Task <IActionResult> CreateAsync([FromBody] CreatePhoneBookDto createPhoneBookDto) { var command = new CreatePhoneBookCommand { Name = createPhoneBookDto.Name }; await _mediator.DispatchAsync(command); return(Ok()); }
public async Task BasicAsyncTest() { var request = new PreActionHandler.Request { Value = "Async Hello!" }; var result = await _mediator.DispatchAsync(request); Assert.AreEqual(nameof(PreActionHandler.RequestRequestPreProcessor), result.Value); }
public async Task BasicAsyncTest() { var request = new BasicHandler.Request { Value = "Async Hello!" }; var result = await _mediator.DispatchAsync(request); Assert.AreEqual(request.Value, result.Value); }
public async Task <IActionResult> SubscribeCommand([FromBody] SubscribeDto value, [FromHeader] Guid userId) { _logger.LogInformation("Subscribe for user:{0}, bookid:{1} ", userId, value.BookId); var book = await _client.GetRequest(new BookDto(), $"{_options.Value.CatalogueUrl}{_options.Value.BookQueryPath}{value.BookId}"); if (book == null) { throw new InvalidDataException("book provided does not exist"); } var command = new SubscribeCommand { BookId = value.BookId, BookName = book.Name, UserId = userId }; await _mediator.DispatchAsync(command); _logger.LogInformation("Subscribed for user:{0}, bookid:{1} ", userId, value.BookId); return(Ok()); }