async Task IAsyncLifetime.DisposeAsync() { var authenticators = await AuthenticatorRepository.GetAllAsync(); for (var i = 0; i < authenticators.Count; i++) { var authenticator = authenticators[i]; await AuthenticatorRepository.DeleteAsync(authenticator); } var categories = await CategoryRepository.GetAllAsync(); for (var i = 0; i < categories.Count; i++) { var category = categories[i]; await CategoryRepository.DeleteAsync(category); } var authenticatorCategories = await AuthenticatorCategoryRepository.GetAllAsync(); for (var i = 0; i < authenticatorCategories.Count; i++) { var authenticatorCategory = authenticatorCategories[i]; await AuthenticatorCategoryRepository.DeleteAsync(authenticatorCategory); } var customIcons = await CustomIconRepository.GetAllAsync(); for (var i = 0; i < customIcons.Count; i++) { var customIcon = customIcons[i]; await CustomIconRepository.DeleteAsync(customIcon); } }
public async Task SetCustomIconAsync(Authenticator auth, CustomIcon icon) { if (icon == null) { throw new ArgumentException("Icon cannot be null"); } var iconId = CustomIcon.Prefix + icon.Id; if (auth.Icon == iconId) { return; } await _customIconService.AddIfNotExists(icon); auth.Icon = iconId; try { await _authenticatorRepository.UpdateAsync(auth); } catch { await _customIconRepository.DeleteAsync(icon); throw; } await _customIconService.CullUnused(); }