コード例 #1
0
        private async Task <ResponseMessage> CreateCustomer(CreatedUserIntegrationEvent integrationEvent)
        {
            var createCustomerCommand = new CreateCustomerCommand(integrationEvent.Id, integrationEvent.Name, integrationEvent.Email, integrationEvent.Cpf);

            using var scope = _serviceScopeFactory.CreateScope();

            var mediator = scope.ServiceProvider.GetRequiredService <IMediatorHandler>();

            var success = await mediator.SendCommand(createCustomerCommand);

            return(new ResponseMessage(success));
        }
コード例 #2
0
ファイル: AuthController.cs プロジェクト: lbeluci/NerdStore
        private async Task <ResponseMessage> RegisterCustomer(RegistrationUser registrationUser)
        {
            var user = await _userManager.FindByEmailAsync(registrationUser.Email);

            var createdUserIntegrationEvent = new CreatedUserIntegrationEvent(Guid.Parse(user.Id), registrationUser.Name, registrationUser.Email, registrationUser.Cpf);

            try
            {
                return(await _bus.RequestAsync <CreatedUserIntegrationEvent, ResponseMessage>(createdUserIntegrationEvent));
            }
            catch
            {
                await _userManager.DeleteAsync(user);

                throw;
            }
        }