public void HeightConvertTest1(double foot, double meters)
        {
            double result = HeightConverter.FootParameters(foot);

            resultad.Should().Be(meters,
                                 $"Height in meters does not correspond to the expected value ({meters})");
        }
Esempio n. 2
0
        private async Task ExecuteOnProfilBase()
        {
            if (!string.IsNullOrWhiteSpace(Profil.DiabetesType) & !string.IsNullOrWhiteSpace(Profil.Glucometer) & !string.IsNullOrWhiteSpace(Settings.GlycemiaUnit) & !string.IsNullOrWhiteSpace(Settings.WeightUnit))
            {
                int x;
                if (!int.TryParse(Diagnostic_Date, out x) | Diagnostic_Date.Length < 4)
                {
                    DependencyService.Get <IMessage>().ShortAlert("Année du Diagnostic Non Valide !");
                    return;
                }
                IsBusy = true;

                var heightconverter = new HeightConverter();
                Profil.Height          = heightconverter.Convert(Profil.Height, Settings.HeighttUnit);
                Profil.Diagnostic_Year = x;
                var restapi = new RestApi();
                (bool, string)result = (false, "");
                if (Source == "ProfilBase")
                {
                    result = await restapi.Resigter(Profil, VerifiedPassword, Facebook_Id);
                }
                if (Source == "FacebookLogin")
                {
                    result = await restapi.EditProfil(Profil, Facebook_Id);
                }

                if (result.Item1)
                {
                    DataStore.UpdateSettings(Settings);
                    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.UpdateProfil(Profil);
                    DependencyService.Get <ISnackBar>().Show(Resources["SuccesMessage"]);
                    Application.Current.MainPage = new MainPage();
                }
                else
                {
                    DependencyService.Get <IMessage>().ShortAlert(result.Item2);
                }

                /*   DataStore.UpdateSettings(Settings);
                 * 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.UpdateProfil(Profil);
                 * Application.Current.MainPage = new MainPage();*/
                IsBusy = false;
            }
        }
 public Profil_Info_ViewModel(IDataStore dataStore, INavigation navigation)
 {
     DataStore         = dataStore;
     Navigation        = navigation;
     HeightConverter   = new HeightConverter();
     Profil            = DataStore.GetProfilAsync().First();
     Settings          = DataStore.GetSettingsAsync().First();
     Profil.Height     = HeightConverter.ConvertBack(Profil.Height, Settings.HeighttUnit);
     Date              = Profil.Birth_Date.ToString("dd/MM/yyyy");
     Diagnostic_Date   = Profil.Diagnostic_Year.ToString();
     EditProfilCommand = new Command(async() =>
     {
         await ExecuteOnEditProfil();
     });
 }
 public WeightStatistique_ViewModel(INavigation navigation, IDataStore dataStore)
 {
     Navigation          = navigation;
     DataStore           = dataStore;
     Settings            = DataStore.GetSettingsAsync().First();
     Profil              = DataStore.GetProfilAsync().First();
     Objectifs           = DataStore.GetObjectifAsync().First();
     Weight_Data         = new ObservableCollection <Weight_Model>();
     WeightConverter     = new WeightConverter();
     HeightConverter     = new HeightConverter();
     Selected_MaxDate    = DateTime.Now.Date;
     Selected_MinDate    = DateTime.Now.Date;
     Selected_Date_Index = 0;
     Message             = Resources["Target_Weight"] + " : " + Objectifs.Weight_Objectif.ToString() + " " + Settings.WeightUnit;
     DateItems           = new ObservableCollection <SfSegmentItem>
     {
         new SfSegmentItem()
         {
             Text = Resources["Today"]
         },
         new SfSegmentItem()
         {
             Text = "7 " + Resources["Days"]
         },
         new SfSegmentItem()
         {
             Text = "14 " + Resources["Days"]
         },
         new SfSegmentItem()
         {
             Text = "30 " + Resources["Days"]
         },
         new SfSegmentItem()
         {
             Text = "90 " + Resources["Days"]
         }
     };
     UpdateData();
     FiltreCommand = new Command(() =>
     {
         UpdateData();
     });
     MessagingCenter.Subscribe <WeightStatistique_Page>(this, "Filter", (sender) =>
     {
         UpdateData();
     });
 }