private void BackToPositive(object sender, TappedRoutedEventArgs e) { PagesUtilities.GetAllCheckBoxesTags(EditNegativeEffectsGrid, out List <int> intList); GlobalContext.RegisterContext.IntNegativePreferences = intList; Frame.Navigate(typeof(EditPositivePage)); }
private async void SearchStrain(object sender, RoutedEventArgs e) { // Get checked effects PagesUtilities.GetAllCheckBoxesTags(MedicalSearchGrid, out List <int> MedicalList); PagesUtilities.GetAllCheckBoxesTags(PositiveSearchGrid, out List <int> PositiveList); // Produce bitmap of effects int MedicalBitMap = StrainToInt.FromIntListToBitmap(MedicalList); int PositiveBitMap = StrainToInt.FromIntListToBitmap(PositiveList); var url = ""; if ((MedicalList.Count == 0) && (PositiveList.Count == 0) && ((StrainName.Text == "") || (StrainName.Text == "e.g. 'Alaska'"))) { // Nothing chosen Status.Text = "Invaild Search! Please enter search parameter"; } else { Status.Text = ""; if ((StrainName.Text != "") && (StrainName.Text != "e.g. 'Alaska'")) { // Search by strain name url = Constants.MakeUrl("strain/name/" + StrainName.Text); GlobalContext.searchType = 1; } else { // Search by effect url = Constants.MakeUrl($"strain/effects?medical={MedicalBitMap}&positive={PositiveBitMap}"); GlobalContext.searchType = 2; } try { // Build request for information var res = HttpManager.Manager.Get(url); if (res == null) { return; } var str = await res.Result.Content.ReadAsStringAsync(); AppDebug.Line(str); if (GlobalContext.searchType == 1) { Frame.Navigate(typeof(StrainSearchResults), str); // Search by name } else if (GlobalContext.searchType == 2) { // Search by effect GlobalContext.searchResult = str; Frame.Navigate(typeof(EffectsSearchResults)); } } catch (Exception ex) { AppDebug.Exception(ex, "SearchStrain"); await new MessageDialog("Failed get: \n" + url, "Exception in Search Strain").ShowAsync(); } } }
private async void EditRegister(object sender, RoutedEventArgs e) { HttpResponseMessage res = null; var user_id = GlobalContext.CurrentUser.Data.UserID; try { progressRing.IsActive = true; PagesUtilities.GetAllCheckBoxesTags(EditNegativeEffectsGrid, out List <int> intList); GlobalContext.RegisterContext.IntNegativePreferences = intList; res = await HttpManager.Manager.Post(Constants.MakeUrl($"edit/{user_id}"), GlobalContext.RegisterContext); if (res != null) { if (res.IsSuccessStatusCode) { Status.Text = "Edit profile Successful!"; PagesUtilities.SleepSeconds(0.5); Frame.Navigate(typeof(DashboardPage), res); } else { Status.Text = "Register failed! Status = " + res.StatusCode; } } else { Status.Text = "Register failed!\nPost operation failed"; } } catch (Exception exc) { AppDebug.Exception(exc, "Register"); } finally { progressRing.IsActive = false; } }
private void GoToEditPositive(object sender, TappedRoutedEventArgs e) { if (GlobalContext.RegisterContext == null) { GlobalContext.RegisterContext = new RegisterRequest(); } GlobalContext.RegisterContext.Username = GlobalContext.CurrentUser.Data.Username; GlobalContext.RegisterContext.Password = "******"; GlobalContext.RegisterContext.DOB = GlobalContext.CurrentUser.Data.DOB; GlobalContext.RegisterContext.Gender = GlobalContext.CurrentUser.Data.Gender; GlobalContext.RegisterContext.Country = GlobalContext.CurrentUser.Data.Country; GlobalContext.RegisterContext.City = GlobalContext.CurrentUser.Data.City; PagesUtilities.GetAllCheckBoxesTags(EditMedicalGrid, out List <int> intList); GlobalContext.RegisterContext.IntListMedicalNeeds = intList; Frame.Navigate(typeof(EditPositivePage), GlobalContext.RegisterContext); }