Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

c# use meditor from service

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);
    }
} 

Source by www.programmingwithwolfgang.com #
 
PREVIOUS NEXT
Tagged: #meditor #service
ADD COMMENT
Topic
Name
4+1 =