Ejemplo n.º 1
0
        public async Task CreateOrUpdateUserSettingsAsync(UserSettings userSettings)
        {
            if (userSettings == null)
            {
                throw new ArgumentNullException(nameof(userSettings));
            }
            var validator         = new UserSettingsValidator();
            var validationResults = await validator.ValidateAsync(userSettings);

            if (!validationResults.IsValid)
            {
                throw new ValidationException("Invalid user settings", validationResults);
            }
            var updateResponse = await _client.IndexDocumentAsync(userSettings);

            if (!updateResponse.IsValid)
            {
                throw new UserStoreException($"Error updating user settings for user ID {userSettings.UserId}");
            }
            await _client.RefreshAsync(Indices.Index <UserSettings>());
        }
Ejemplo n.º 2
0
 public UserSettingsValidatorTests()
 {
     _validator = new UserSettingsValidator();
 }