private async void TestList_ItemSelected(object sender, SelectedItemChangedEventArgs e) { string testFile = e.SelectedItem as string; string testURL = "https://raw.githubusercontent.com/garciart/TestMate/master/Tests/" + testFile; try { byte[] returnedBytes = await AppFunctions.DownloadFileAsync(testURL); File.WriteAllBytes(String.Format("{0}/{1}", Constants.AppDataPath, testFile), returnedBytes); await this.DisplayAlert("Test Mate", AppResources.DownloadSuccessMessage, "OK"); OnAppearing(); // await Application.Current.MainPage.Navigation.PopAsync(); } catch (Exception ex) { await this.DisplayAlert("Test Mate", String.Format(AppResources.DownloadErrorMessage, ex.Message), "OK"); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void UpdateDatabaseButton_Clicked(object sender, EventArgs e) { bool answer = await DisplayAlert("Quick Meds", AppResources.UpdateConfirm, AppResources.ButtonYes, AppResources.ButtonNo); if (answer) { string databaseFile = "QuickMeds.db"; string databaseURL = "https://raw.githubusercontent.com/garciart/QuickMeds/master/Database/" + databaseFile; try { byte[] returnedBytes = await AppFunctions.DownloadFileAsync(databaseURL); File.WriteAllBytes(string.Format("{0}/{1}", Constants.AppDataPath, databaseFile), returnedBytes); await DisplayAlert("Quick Meds", AppResources.DownloadSuccessMessage, "OK"); await Application.Current.MainPage.Navigation.PopAsync(); } catch (Exception ex) { await DisplayAlert("Quick Meds", string.Format(AppResources.DownloadErrorMessage, ex.Message), "OK"); } } }