async void Handle_ItemTapped(object sender, ItemTappedEventArgs e) { if (e.Item == null) { return; } var samplingSelected = (Sampling)e.Item; Application.Current.Properties["fase"] = samplingSelected.fase; Application.Current.Properties["id-sampling"] = samplingSelected.id; Application.Current.Properties["sampling-type-id"] = samplingSelected.sampling_type_id; if (samplingSelected.fase == 1) { Application.Current.Properties["preliminar-done"] = 0; Application.Current.Properties["definitive-done"] = 0; } else { Application.Current.Properties["preliminar-done"] = 2; Application.Current.Properties["definitive-done"] = 0; } var etapasPage = new Etapas(); await Navigation.PushAsync(etapasPage); //Deselect Item ((ListView)sender).SelectedItem = null; }
private async Task crearMue_Clicked(object sender, EventArgs e) { if (!String.IsNullOrEmpty(nombreMuestreoEntry.Text) && !String.IsNullOrEmpty(cantMuestrasEntry.Text)) { if (await getSamplings(nombreMuestreoEntry.Text) == false) { var client = new HttpClient { BaseAddress = new Uri("https://app-produ.herokuapp.com") }; var idType = samplingTypes.FirstOrDefault(x => x.Value == tipo.SelectedItem.ToString()).Key; var newSampling = new Sampling { nombre = nombreMuestreoEntry.Text, cantMuestras = System.Convert.ToInt32(cantMuestrasEntry.Text), cantMuestrasTotal = System.Convert.ToInt32(cantMuestrasEntry.Text), descripcion = descripcionMuestreoEditor.Text, fase = 1, sampling_type_id = idType, project_id = (int)Application.Current.Properties["id-project"], muestrasActual = 0, token = Application.Current.Properties["currentToken"].ToString() }; string jsonData = JsonConvert.SerializeObject(newSampling); var content = new StringContent(jsonData, Encoding.UTF8, "application/json"); HttpResponseMessage response = await client.PostAsync("/samplings/newsampling.json", content); if (response.StatusCode == HttpStatusCode.Created) { var result = await response.Content.ReadAsStringAsync(); var jobject = JObject.Parse(result); var data = JsonConvert.DeserializeObject <Sampling>(jobject["muestreo"].ToString()); try { Application.Current.Properties["id-sampling"] = data.id; Application.Current.Properties["fase"] = data.fase; Application.Current.Properties["sampling-type-id"] = data.sampling_type_id; await crearFaseAsync(); var etapasPage = new Etapas(); await Navigation.PushAsync(etapasPage); this.Navigation.RemovePage(this.Navigation.NavigationStack[this.Navigation.NavigationStack.Count - 2]); } catch (Exception) { } } } else { await DisplayAlert("Error!", "El nombre del muestreo ya existe.", "OK"); } } else { await DisplayAlert("Error!", "Espacios vacíos!\nPor favor inserte el Nombre de Muestreo y la Cantidad de Muestras!", "OK"); } }