public async Task <IActionResult> BuyBookAsync(PurchaseBookCommand command) { var email = User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Email).Value; command.UserEmail = email; await Mediator.Send(command); return(NoContent()); }
private bool Handle(PurchaseBookCommand command) { var provider = DependencyInjectorStub.Get((s, c) => { BootStrapper.RegisterServices(s, c); s.AddScoped(x => MockRepository.GetContext()); s.AddScoped <IBusPublisher>(x => Bus); s.AddScoped <IDateTimeService>(x => DateTimeServiceStub.Create()); }); var handler = provider.GetRequiredService <IRequestHandler <PurchaseBookCommand, bool> >(); return(handler.Handle(command, CancellationToken.None).GetAwaiter().GetResult()); }