Exemplo n.º 1
0
        public async Task Handle(UserCreatedEvent message)
        {
            if (message.Error)
            {
                return;
            }

            using (_logger.BeginScope(message))
            {
                try
                {
                    await _database.AddAsync(new ApplicationUser
                    {
                        Id       = message.Id,
                        Name     = message.Name,
                        Password = message.Hash,
                        Salt     = message.Salt
                    });

                    await _database.SaveChangesAsync();

                    _logger.LogInformation(EventIds.UserManager.UserManagment, $"User {message.Name} added to the Readmodel");
                }
                catch (Exception e)
                {
                    _logger.LogError(EventIds.UserManager.UserManagment, e, $"User {message.Name} adding Failed");
                }
            }
        }