public Task ValidateAddress(NewRegistrationEvent domainEvent) { _logger.LogDebug("Validate Address..."); // Would typically call asynchronous method to retrieve information // required to validation. return(Task.CompletedTask); }
public static async Task Handle(NewRegistrationEvent newRegistrationEvent) { var dl = new HandlerDataLayer(); var conference = await dl.GetConferenceItemById(newRegistrationEvent.ConferenceId); conference.Attendees.Add(new Attendee { Name = newRegistrationEvent.Name, FirstName = newRegistrationEvent.FirstName, Email = newRegistrationEvent.Email, Company = newRegistrationEvent.Company, RegistrationId = newRegistrationEvent.Id }); await dl.SaveConferenceItem(conference); }
public IEnumerable <EventBase> Handle(NewRegistration command) { var newRegistrationEvent = new NewRegistrationEvent { Id = Guid.NewGuid(), Company = command.Company, FirstName = command.FirstName, Name = command.Name, ConferenceId = command.ConferenceId, Email = command.Email }; yield return(newRegistrationEvent); }
public static async Task Handle(NewRegistrationEvent newRegistrationEvent) { var dl = new HandlerDataLayer(); var item = await dl.GetAttendeeListItemByEmail(newRegistrationEvent.Email); if (item == null) { item = new AttendeeListItem { Email = newRegistrationEvent.Email, Count = 0 }; } item.Name = newRegistrationEvent.Name; item.FirstName = newRegistrationEvent.FirstName; item.Company = newRegistrationEvent.Company; item.Count++; await dl.SaveAttendeeListItem(item); }
public async Task <Customer> OnRegistration(RegistrationCommand command) { // Create domain entities from the command and associate them. var customer = Customer.Register(command.Prefix, command.FirstName, command.LastName, command.Age); var address = Address.Define(customer.Id, command.AddressLine1, command.AddressLine2, command.City, command.State, command.ZipCode); customer.AssignAddress(address); // Save the domain entities to the repository. await _customerRepo.SaveAsync(customer); // Notify other application components that a new registration was created. var domainEvent = new NewRegistrationEvent(customer); await _messaging.PublishAsync(domainEvent); return(customer); }