public async void OnClickedFinalizar(object sender, EventArgs args) { if (nombre.Text != null && password.Text != null && correo.Text != null && password.Text != null && telefono.Text != null && password.Text.Equals(passwordconf.Text)) { MD5HashX2 pwtohash = new MD5HashX2(); User usuario = new User(); usuario.name = nombre.Text; usuario.Lastname = apellido.Text; usuario.Id = userid.Text; usuario.Emal = correo.Text; usuario.Password = pwtohash.MD5Hash(password.Text); usuario.City = ciudad.SelectedIndex.ToString(); usuario.Address = address.Text; usuario.Cellnumber = telefono.Text; usuario.Gender = lstViewGeneros.SelectedIndex.ToString(); usuario.Birdhdate = fechaNacimiento.Date; usuario.Datapolicy = true; usuario.Termsandconditions = true; Repository repository = new Repository(); try { userCreate user = repository.postUserCreate(usuario).Result; Dialogs.ShowLoading(user.Message.ToString());; await Task.Delay(2000); Dialogs.HideLoading(); InicioPage myHomePage = new InicioPage(); NavigationPage.SetHasNavigationBar(myHomePage, false); await Navigation.PushModalAsync(myHomePage); } catch (Exception ex) { await DisplayAlert("Registrarse Error", ex.Message, "Gracias"); } } else { await DisplayAlert("Registrarse", "Verifique la Información", "Gracias"); } }
/**************************************************************************/ /*********************************Usuario, Post Usuario, Update Usuario, Recuperar Pw, Login*****************************************/ public async Task <Login> ConnectUser(string id, string password) { object userInfos = new { id = id, password = mdpass.MD5Hash(password) }; var jsonObj = JsonConvert.SerializeObject(userInfos); using (HttpClient client = new HttpClient()) { StringContent content = new StringContent(jsonObj.ToString(), Encoding.UTF8, "application/json"); var request = new HttpRequestMessage() { RequestUri = new Uri("https://crmpuntos.oliviadirect.co/services/user/login.php"), Method = HttpMethod.Post, Content = content }; //you can add headers //request.Headers.Add("key", "value"); var response = await client.SendAsync(request).ConfigureAwait(false); string dataResult = response.Content.ReadAsStringAsync().Result; Login result = JsonConvert.DeserializeObject <Login>(dataResult); return(result); } }