public async Task HandleAsync(IDomainEvent <EmployeeAggregate, EmployeeId, EmployeeAddedEvent> domainEvent, CancellationToken cancellationToken) { var employeeCommand = new EmployeeAddCommand(domainEvent.AggregateIdentity, domainEvent.AggregateEvent.EmployeeRecord); await CommandBus.PublishAsync(employeeCommand, CancellationToken.None).ConfigureAwait(false); }
public async Task HandleAsync(IReadOnlyCollection <IDomainEvent> domainEvents, CancellationToken cancellationToken) { var domainEvent = domainEvents.FirstOrDefault(); var employeeCommand = new EmployeeAddCommand((EmployeeId)domainEvent.GetIdentity(), ((EmployeeAddedEvent)domainEvent.GetAggregateEvent()).EmployeeRecord); await CommandBus.PublishAsync(employeeCommand, CancellationToken.None).ConfigureAwait(false); }
public async Task <Employee> Post(EmployeeRequestModel request) { var id = Guid.NewGuid().ToString(); var employeeId = new EmployeeId($"employee-{id}"); var employeeData = new Employee(employeeId, request.FullName, request.Department, ""); var employeeCommand = new EmployeeAddCommand(employeeId, employeeData); await CommandBus.PublishAsync(employeeCommand, CancellationToken.None).ConfigureAwait(false); return(employeeData); }
public async Task <EmployeeId> Post(CreateEmployeeRequest request) { var id = Guid.NewGuid().ToString(); var employeeId = new EmployeeId("employee-" + id); var employeeRecord = new Employee(employeeId, request.FirstName, request.LastName); var employeeCommand = new EmployeeAddCommand(employeeId, employeeRecord); await CommandBus.PublishAsync(employeeCommand, CancellationToken.None).ConfigureAwait(false); return(employeeId); }