Skip to content

Instantly share code, notes, and snippets.

@babaktaremi
Last active January 5, 2021 17:50
Show Gist options
  • Save babaktaremi/f25978fcd4b4600c9a597901b3b1b7b2 to your computer and use it in GitHub Desktop.
Save babaktaremi/f25978fcd4b4600c9a597901b3b1b7b2 to your computer and use it in GitHub Desktop.
//Command Model
public class CreateCustomerCommandHandler : IRequestHandler<CreateCustomerCommand, Customer>
{
private readonly ICustomerRepository _customerRepository;
public CreateCustomerCommandHandler(ICustomerRepository customerRepository)
{
_customerRepository = customerRepository;
}
public async Task<Customer> Handle(CreateCustomerCommand request, CancellationToken cancellationToken)
{
return await _customerRepository.AddAsync(request.Customer);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment