private async void Button_Clicked(object sender, EventArgs e) { MaterialControls control = new MaterialControls(); control.ShowLoading("Iniciando sesion..."); BaseUrl get = new BaseUrl(); string url = get.url; var usuario = user.Text; var contraseña = password.Text; if (string.IsNullOrEmpty(usuario) || string.IsNullOrEmpty(contraseña)) { message.IsVisible = true; } else { CheckUrlConnection test = new CheckUrlConnection(); bool inf = test.TestConnection(); if (inf == true) { Usuario users = new Usuario() { user_Name = usuario, user_Password = contraseña }; HttpClient client = new HttpClient(); string controlador = "/Api/usuario/auth_users.php"; client.BaseAddress = new Uri(url); string json = JsonConvert.SerializeObject(users); var content = new StringContent(json, Encoding.UTF8, "application/json"); var response = await client.PostAsync(controlador, content); if (response.IsSuccessStatusCode) { var res = await response.Content.ReadAsStringAsync(); var result = res.ToString().Replace('"', ' ').Trim(); App.Current.Properties["name"] = result; App.Current.Properties["IsLoggedIn"] = true; iml.ShowMainPage(); } else { control.ShowAlert("Los datos estan incorrectos", "Error", "Ok"); } } else { control.ShowAlert("No se pudo conectar con el servidor", "Error", "Ok"); } } }
public Home() { InitializeComponent(); BaseUrl get = new BaseUrl(); string url = get.url; string server = url + "/Api"; CheckUrlConnection test = new CheckUrlConnection(); bool result = test.TestConnection(); if (result != true) { control.ShowAlert("No se pudo conectar con el servidor", "Error", "Ok"); } }
public Profile() { InitializeComponent(); id = model.getName(); BaseUrl get = new BaseUrl(); string url = get.url; string server = url + "/Api"; CheckUrlConnection test = new CheckUrlConnection(); bool result = test.TestConnection(); if (result != true) { control.ShowAlert("No se pudo conectar con el servidor", "Error", "Ok"); } else { getVitals(id); getPersonalInfo(id); } }
private async void Button_Clicked(object sender, EventArgs e) { MaterialControls control = new MaterialControls(); control.ShowLoading("Verificando..."); BaseUrl get = new BaseUrl(); string baseurl = get.url; var id = dui.Text; CheckUrlConnection test = new CheckUrlConnection(); bool inf = test.TestConnection(); if (inf == true) { ; string url = baseurl + "/Api/paciente/verify.php?dui=" + id; HttpClient client = new HttpClient(); HttpResponseMessage connect = await client.GetAsync(url); if (connect.StatusCode == HttpStatusCode.OK) { var response = await client.GetStringAsync(url); var lista = JsonConvert.DeserializeObject <Pacientes>(response); var idpaciente = lista.idpaciente; await Navigation.PushAsync(new Register(idpaciente)); } else { control.ShowAlert("Lo sentimos usted no esta registrado", "Error", "ok"); } } else { control.ShowAlert("No se pudo conectar con el servidor", "Error", "Ok"); } }