public async Task Delete(string name, string providerName, string providerKey) { LinSetting setting = await _settingRepository.FindAsync(name, providerName, providerKey);; if (setting != null) { await _settingRepository.DeleteAsync(setting.Id); } }
public override async Task <int> HandleCommand(DeleteSettingCommand request, CancellationToken cancellationToken) { Setting setting = null; if (request.Model == 0) { throw new BusinessException("Setting.NotSelected"); } else { setting = await settingQueries.GetByIdAsync(request.Model); if (setting == null) { throw new BusinessException("Setting.NotSelected"); } } var rs = -1; using (var conn = DALHelper.GetConnection()) { conn.Open(); using (var trans = conn.BeginTransaction()) { try { if (await settingRepository.DeleteAsync(setting.Id) > 0) { rs = 0; } } catch (Exception ex) { throw ex; } finally { if (rs == 0) { trans.Commit(); } else { try { trans.Rollback(); } catch { } } } } } return(rs); }
public async Task Cache_Should_Invalidator_WhenSettingChanged() { // Arrange // GetOrNullAsync will cache language. await _settingManagementStore.GetOrNullAsync("MySetting2", UserSettingValueProvider.ProviderName, _testData.User1Id.ToString()); // Act var lang = await _settingRepository.FindAsync("MySetting2", UserSettingValueProvider.ProviderName, _testData.User1Id.ToString()); await _settingRepository.DeleteAsync(lang); // Assert (await _cache.GetAsync( SettingCacheItem.CalculateCacheKey("MySetting2", UserSettingValueProvider.ProviderName, _testData.User1Id.ToString()))).ShouldBeNull(); }
public async Task Delete(Guid id) { await _settingRepository.DeleteAsync(id); }