public DataTypeSelection_ViewModel(INavigation navigation, Settings_Model profil) { Navigation = navigation; Profil = profil; GlucoseCommand = new Command(async() => { await ExecuteOnGlucoseClicked(); }); PressionCommand = new Command(async() => { await ExecuteOnPressionClicked(); }); Hb1AcCommand = new Command(async() => { await ExecuteOnHb1acClicked(); }); WeightCommand = new Command(async() => { await ExecuteOnWeightClicked(); }); DrugsCommand = new Command(async() => { await ExecuteOnDrugsClicked(); }); }
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 Add_Data_Page(string source, Settings_Model profil) { InitializeComponent(); var datastore = new DataStores(); BindingContext = new AddData_ViewModel(source, Navigation, datastore, profil); TimePicker.Time = new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); }
public AddHb1Ac_View(string source, Settings_Model profil, object data) { InitializeComponent(); var datastore = new DataStores(); BindingContext = new AddData_ViewModel(source, Navigation, datastore, profil, data); TimePicker.Time = new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); DatePicker.MaximumDate = DateTime.Now.Date; }
public AddData_ViewModel(string source, INavigation navigation, IDataStore _datastore, Settings_Model profil, object data = null) { this.Navigation = navigation; this.dataStore = _datastore; if (source == "Add_Data") { IsVisible = true; Glucose = new Glucose_Model(); Pression = new Pression_Model(); Hb1Ac = new Hb1Ac_Model(); Drug = new Drugs_Model(); Insuline = new Insulune_Model(); Weight = new Weight_Model(); GlycemiaConverter = new GlycemiaConverter(); WeightConverter = new WeightConverter(); PermissionsRequest = new PermissionsRequest(); } else { IsVisible = false; Glucose = (typeof(Glucose_Model) == data.GetType()) ? data as Glucose_Model : null; Pression = (typeof(Pression_Model) == data.GetType()) ? data as Pression_Model : null; Hb1Ac = (typeof(Hb1Ac_Model) == data.GetType()) ? data as Hb1Ac_Model : null; Weight = (typeof(Weight_Model) == data.GetType()) ? data as Weight_Model : null; } Profil = profil; SaveGlucoseCommand = new Command(async() => { await ExecuteOnSaveGlucose(); }); SaveHb1AcCommand = new Command(async() => { await ExecuteOnSaveHb1ac(); }); SavePressionCommand = new Command(async() => { await ExecuteOnSavePression(); }); SaveWeightCommand = new Command(async() => { await ExecuteOnSaveWeight(); }); TakePictureCommand = new Command(async() => { await ExecuteOnTakePicture(); }); PictureTappedCommand = new Command(async() => { await ExecuteOnPictureTapped(); }); }
private async Task ExecuteOnLogin() { IsBusy = true; if (Settings.Remember_me != Remember_me) { Settings.Remember_me = Remember_me; DataStore.UpdateSettings(Settings); } if (Remember_me) { CrossSecureStorage.Current.SetValue("username", Username); CrossSecureStorage.Current.SetValue("password", Password); } // Application.Current.MainPage = new MainPage(); if (!string.IsNullOrEmpty(Username) & !string.IsNullOrEmpty(Password)) { var result = await RestApi.Login(Username.Trim(), Password); if (result.Item1) { var result2 = await RestApi.GetProfile(); if (result2.Item1) { DataStore.DeleteAllProfiles(); DataStore.AddProfil(JsonConvert.DeserializeObject <Profil_Model>(result2.Item2)); if (DataStore.GetSettingsAsync().Count() < 1) { var settings = new Settings_Model(); DataStore.AddSettings(settings); } Application.Current.MainPage = new MainPage(); } else { DependencyService.Get <IMessage>().ShortAlert(result2.Item2); } } else { DependencyService.Get <IMessage>().ShortAlert(result.Item2); } } IsBusy = false; }
public App(IOAuth2Service oAuth2Service) { Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("MjQzNzAyQDMxMzgyZTMxMmUzMGlDWTJIVjZqZ2swTU1GOFdDaVhrQkhYMktvZjV0TjRtUldJWFN4akpKRlU9"); InitializeComponent(); var datastore = new DataStores(); if (datastore.GetSettingsAsync().Count() > 0) { CurrentLanguage = (!string.IsNullOrWhiteSpace(datastore.GetSettingsAsync().First().Language)) ? datastore.GetSettingsAsync().First().Language : CultureInfo.CurrentUICulture.TwoLetterISOLanguageName; } else { var settings = new Settings_Model(); var Objectifs = new Objectif_Model(); Objectifs.Max_Glycemia = 120; Objectifs.Min_Glycemia = 70; Objectifs.Weight_Objectif = 80; Objectifs.Steps_Objectif = 10000; datastore.AddObjectif(Objectifs); datastore.AddSettings(settings); CurrentLanguage = datastore.GetSettingsAsync().First().Language; } if (CrossSecureStorage.Current.HasKey("first_use")) { var tokenController = new TokenController(); if (tokenController.Token_Expired()) { MainPage = new NavigationPage(new Login_Page()); } else { MainPage = new NavigationPage(new MainPage()); } } else { MainPage = new NavigationPage(new FirstUseLanguage_Page()); } }
private async Task LoginFacebookAsync() { try { if (_facebookService.IsLoggedIn) { _facebookService.Logout(); } EventHandler <FBEventArgs <string> > userDataDelegate = null; userDataDelegate = async(object sender, FBEventArgs <string> e) => { switch (e.Status) { case FacebookActionStatus.Completed: /* System.Diagnostics.Debug.WriteLine(CrossFacebookClient.Current.ActiveToken); * var facebookProfile = await Task.Run(() => JsonConvert.DeserializeObject<FacebookProfile>(e.Data)); * * var profil = new Profil_Model(); * CultureInfo provider = CultureInfo.InvariantCulture; * profil.Birth_Date = DateTime.ParseExact(facebookProfile.Birthday, "MM/dd/yyyy", provider); * profil.FirstName = facebookProfile.FirstName; * profil.LastName = facebookProfile.LastName; * profil.Sexe = facebookProfile.Gender.First().ToString().ToUpper() + facebookProfile.Gender.Substring(1); * profil.Email = facebookProfile.Email; * profil.Avatar = facebookProfile.Picture.Data.Url; * // Application.Current.MainPage = new MainPage(); * * var result = await RestApi.SocialChack("facebook", facebookProfile.Id); * if (result.Item1) * { * if (result.Item2) * { * var result2 = await RestApi.GetProfile(); * if (result2.Item1) * { * DataStore.DeleteAllProfiles(); * DataStore.AddProfil(JsonConvert.DeserializeObject<Profil_Model>(result2.Item2)); * if (DataStore.GetSettingsAsync().Count() < 1) * { * var settings = new Settings_Model(); * DataStore.AddSettings(settings); * } * * Application.Current.MainPage = new MainPage(); * } * else * { * DependencyService.Get<IMessage>().ShortAlert(result2.Item2); * } * } * else * { * DataStore.DeleteAllProfiles(); * DataStore.AddProfil(profil); * await Navigation.PushAsync(new Profil_Base_Page(facebookProfile.Id, facebookProfile.Id), true); * } * } * else * { * DependencyService.Get<IMessage>().ShortAlert(result.Item3); * }*/ var Result = await RestApi.SocialChack(CrossFacebookClient.Current.ActiveToken); if (Result.Item1) { var result2 = await RestApi.GetProfile(); if (result2.Item1) { var profil = JsonConvert.DeserializeObject <Profil_Model>(result2.Item2); if (!string.IsNullOrEmpty(profil.DiabetesType)) { DataStore.DeleteAllProfiles(); DataStore.AddProfil(profil); if (DataStore.GetSettingsAsync().Count() < 1) { var settings = new Settings_Model(); DataStore.AddSettings(settings); } Application.Current.MainPage = new MainPage(); } else { DataStore.DeleteAllProfiles(); DataStore.AddProfil(profil); var facebookProfile = await Task.Run(() => JsonConvert.DeserializeObject <FacebookProfile>(e.Data)); await Navigation.PushAsync(new Profil_Base_Page("FacebookLogin", facebookProfile.Id, facebookProfile.Id), true); } } else { DependencyService.Get <IMessage>().ShortAlert(result2.Item2); } } else { DependencyService.Get <IMessage>().ShortAlert(Result.Item2); } break; case FacebookActionStatus.Canceled: await App.Current.MainPage.DisplayAlert("Facebook Auth", "Canceled", "Ok"); break; case FacebookActionStatus.Error: await App.Current.MainPage.DisplayAlert("Facebook Auth", "Error", "Ok"); break; case FacebookActionStatus.Unauthorized: await App.Current.MainPage.DisplayAlert("Facebook Auth", "Unauthorized", "Ok"); break; } _facebookService.OnUserData -= userDataDelegate; }; _facebookService.OnUserData += userDataDelegate; string[] fbRequestFields = { "email", "birthday", "first_name", "picture", "gender", "last_name" }; string[] fbPermisions = { "email", "user_birthday", "user_gender" }; await _facebookService.RequestUserDataAsync(fbRequestFields, fbPermisions); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } }
public DataTypeSelection_View(Settings_Model profil) { InitializeComponent(); BindingContext = new DataTypeSelection_ViewModel(Navigation, profil); }
public void DeleteSettings(Settings_Model data) { _connection.Delete(data); }
public void AddSettings(Settings_Model data) { _connection.Insert(data); }
public void UpdateSettings(Settings_Model data) { _connection.Update(data); }