public async Task Set <T>(string key, Guid identityId, T value) { var settingString = JsonSerializer.Serialize(value); var setting = await _settingsStorage.Get(key, identityId); if (setting == default(Setting)) { setting = new Setting { IdentityId = identityId, KeyField = key, ValueField = settingString, Accessed = DateTimeOffset.Now }; await _settingsStorage.Create(setting); return; } if (setting.ValueField.Equals(settingString)) { // No need to update when the value is the same return; } setting.Accessed = DateTimeOffset.Now; setting.ValueField = settingString; await _settingsStorage.Update(setting); }