public async Task <Guid> StartRegistrationAsync(UserRegistrationForm registrationForm) { if (registrationForm == null) { throw new ArgumentNullException(nameof(registrationForm)); } var userRegistrationProcess = new UserRegistrationProcess(registrationForm); await _userRegistrationProcessRepository.SaveAsync(userRegistrationProcess); return(userRegistrationProcess.UserId); }
public async Task HandleAsync(UserRegistrationStarted @event) { var indexResult = await _userByEmailIndex.AddAsync(@event.Form.Email, @event.UserId); var process = await GetProcessOrExceptionAsync(@event.UserId); switch (indexResult) { case IndexResult.EmailAccepted: process.HandleEmailAccepted(); break; case IndexResult.EmailRejected: process.HandleEmailRejected(); break; default: throw new ArgumentOutOfRangeException(); } await _userRegistrationProcessRepository.SaveAsync(process); }