コード例 #1
0
        public async Task <RestoreResult> RestoreAndUpdateAsync(Backup backup)
        {
            var(authsAdded, authsUpdated) = await _authenticatorService.AddOrUpdateManyAsync(backup.Authenticators);

            var result = new RestoreResult
            {
                AddedAuthenticatorCount = authsAdded, UpdatedAuthenticatorCount = authsUpdated
            };

            if (backup.Categories != null)
            {
                var(added, updated) = await _categoryService.AddOrUpdateManyAsync(backup.Categories);

                result.AddedCategoryCount   = added;
                result.UpdatedCategoryCount = updated;
            }

            if (backup.AuthenticatorCategories != null)
            {
                var(added, updated) =
                    await _authenticatorCategoryService.AddOrUpdateManyAsync(backup.AuthenticatorCategories);

                result.AddedAuthenticatorCategoryCount   = added;
                result.UpdatedAuthenticatorCategoryCount = updated;
            }

            if (backup.CustomIcons != null)
            {
                result.AddedCustomIconCount = await _customIconService.AddManyAsync(backup.CustomIcons);
            }

            return(result);
        }