public SignUp_ViewModel(INavigation navigation, IDataStore dataStore, string source, string password, string facebook_id = null) { DataStore = dataStore; Navigation = navigation; Facebook_Id = facebook_id; Profil = new Profil_Model(); Settings = new Settings_Model(); Source = source; if (source == "ProfilBase" | source == "FacebookLogin") { if (DataStore.GetProfilAsync().Count() > 0) { Profil = DataStore.GetProfilAsync().First(); VerifiedPassword = password; } Settings = DataStore.GetSettingsAsync().First(); } SignUpCommand = new Command(async() => { await ExecuteOnSignUp(); }); ProfilBaseCommand = new Command(async() => { await ExecuteOnProfilBase(); }); }
public void DeleteProfil(Profil_Model data) { _connection.DeleteAll <Profil_Model>(); }
public void AddProfil(Profil_Model data) { _connection.Insert(data); }
public void UpdateProfil(Profil_Model data) { _connection.Update(data); }
public async Task <(bool, string)> EditProfil(Profil_Model user, string facebook_id = null) { string error_msg = null; bool Succes = false; if (true) { var keyvalues = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("email", user.Email), new KeyValuePair <string, string>("facebook_id", facebook_id), new KeyValuePair <string, string>("avatar", user.Avatar), new KeyValuePair <string, string>("firstname", user.FirstName), new KeyValuePair <string, string>("lastname", user.LastName), new KeyValuePair <string, string>("birthday", user.Birth_Date.ToString("yyyy-MM-dd")), new KeyValuePair <string, string>("diabetestype", user.DiabetesType), new KeyValuePair <string, string>("glucometer", user.Glucometer), new KeyValuePair <string, string>("diagnosis_date", user.Diagnostic_Year.ToString()), new KeyValuePair <string, string>("height", user.Height.ToString()), new KeyValuePair <string, string>("sex", user.Sexe), }; try { string token = CrossSecureStorage.Current.GetValue("acces_token"); HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); var request = new HttpRequestMessage(HttpMethod.Post, "http://" + ipAdress + "/api/patient/profile/edit") { Content = new FormUrlEncodedContent(keyvalues) }; client.Timeout = TimeSpan.FromSeconds(20); var responce = await client.SendAsync(request); var json = await responce.Content.ReadAsStringAsync(); dynamic obj = JsonConvert.DeserializeObject(json); if (obj.success == true) { Succes = true; } else { error_msg = obj.error; } } catch (Exception ex) { error_msg = ex.Message; } } else { error_msg = Resources["InternetMessage"]; } return(Succes, error_msg); }
public async Task <(bool, string)> Resigter(Profil_Model user, string password, string facebook_id = null) { string error_msg = null; bool Succes = false; if (true) { var keyvalues = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("email", user.Email), // new KeyValuePair<string, string>("facebook_id" , facebook_id), new KeyValuePair <string, string>("avatar", user.Avatar), new KeyValuePair <string, string>("firstname", user.FirstName), new KeyValuePair <string, string>("lastname", user.LastName), new KeyValuePair <string, string>("birthday", user.Birth_Date.ToString("yyyy-MM-dd")), new KeyValuePair <string, string>("password", password), new KeyValuePair <string, string>("diabetestype", user.DiabetesType), new KeyValuePair <string, string>("glucometer", user.Glucometer), new KeyValuePair <string, string>("diagnosis_date", user.Diagnostic_Year.ToString()), new KeyValuePair <string, string>("height", user.Height.ToString()), new KeyValuePair <string, string>("sex", user.Sexe), }; try { var request = new HttpRequestMessage(HttpMethod.Post, "http://" + ipAdress + "/api/auth/register") { Content = new FormUrlEncodedContent(keyvalues) }; var client = new HttpClient(); client.Timeout = TimeSpan.FromSeconds(20); var responce = await client.SendAsync(request); var json = await responce.Content.ReadAsStringAsync(); // System.Diagnostics.Debug.WriteLine(json); dynamic obj = JsonConvert.DeserializeObject(json); if (obj.registred == true) { Succes = true; string token = obj["token"]; token = token.Substring(7, token.Length - 7); CrossSecureStorage.Current.SetValue("LogguedIn", "True"); CrossSecureStorage.Current.SetValue("acces_token", token); } else { error_msg = obj.error; } } catch (Exception ex) { error_msg = ex.Message; } } else { error_msg = Resources["InternetMessage"]; } return(Succes, error_msg); }