private async void UploadConfigButton_Click(object sender, RoutedEventArgs e) { try { var helper = new RoamingObjectStorageHelper(); var portfolio = Portfolio.PurchaseList; if (portfolio == null || portfolio.Count == 0) { await new ContentDialog() { Title = "Empty portfolio", Content = "Your current portfolio is empty.", DefaultButton = ContentDialogButton.Primary, PrimaryButtonText = "Export", IsPrimaryButtonEnabled = false, CloseButtonText = "Cancel", RequestedTheme = ((Frame)Window.Current.Content).RequestedTheme }.ShowAsync(); } else { ContentDialog exportDialog = new ContentDialog() { Title = $"Export {portfolio.Count} purchases?", Content = "This will create a backup of your current portfolio in the cloud.", DefaultButton = ContentDialogButton.Primary, PrimaryButtonText = "Export", CloseButtonText = "Cancel", RequestedTheme = ((Frame)Window.Current.Content).RequestedTheme }; var response = await exportDialog.ShowAsync(); if (response == ContentDialogResult.Primary) { await helper.SaveFileAsync(portfolioKey, portfolio); } } } catch (Exception ex) { await new MessageDialog("Error uploading your portfolio. Try again later.").ShowAsync(); } }
//Saves the Website List in Roaming Storage to allow cross device sync. //TODO: At a prompt when file gets over 100kb. public static async Task SaveAsync(List <Website> keyLargeObject) { RoamingObjectStorageHelper helper = new RoamingObjectStorageHelper(); await helper.SaveFileAsync("keyWebsites", _websites); }