public static async void SerializeAppData(AppModel appModel) { StorageFolder localFolder = ApplicationData.Current.LocalFolder; StorageFile textFile = await localFolder.CreateFileAsync("app.json", CreationCollisionOption.ReplaceExisting); // Open the file... using (IRandomAccessStream textStream = await textFile.OpenAsync(FileAccessMode.ReadWrite)) { // write the JSON string! using (DataWriter textWriter = new DataWriter(textStream)) { textWriter.WriteString(JsonConvert.SerializeObject(appModel)); await textWriter.StoreAsync(); } } }
private async void Enviar_Click(object sender, RoutedEventArgs e) { progressBar.Visibility = System.Windows.Visibility.Visible; btnEnviar.IsEnabled = false; var weddingId = this.weddingPublicId.Text; if (weddingPublicId.Text != string.Empty) { var client = new HttpClient(); await client.GetStringAsync("http://" + App.baseUrl + "/api/Wedding/" + weddingId) .ContinueWith(t => { var wedding = JsonConvert.DeserializeObject<WeddingDto>(t.Result); if (wedding != null) { Dispatcher.BeginInvoke(() => { AppModel appModel = new AppModel() { CurrentWeddingId = weddingId }; Utils.SerializeAppData(appModel); NavigationService.Navigate(new Uri("/Views/UploaderPage.xaml?weddingId=" + weddingId, UriKind.Relative)); }); } else { ShowErrorMessage(weddingId); } Dispatcher.BeginInvoke(() => { progressBar.Visibility = System.Windows.Visibility.Collapsed; btnEnviar.IsEnabled = true; }); }); } }