services.AddMediatR(Assembly.GetExecutingAssembly());
services.AddMediatR(Assembly.GetExecutingAssembly(), typeof(ICustomerNameUpdateService).Assembly);
public class CreateOrderCommandHandler : IRequestHandler<CreateOrderCommand, Order>
{
private readonly IOrderRepository _orderRepository;
public CreateOrderCommandHandler(IOrderRepository orderRepository)
{
_orderRepository = orderRepository;
}
public async Task<Order> Handle(CreateOrderCommand request, CancellationToken cancellationToken)
{
return await _orderRepository.AddAsync(request.Order);
}
}