public Weight_Model Convert(Weight_Model value, string parameter) { if (parameter == "lbs") { value.Weight = Math.Round((value.Weight * 2.205), 3); } return(value); }
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 ExecuteOnSync() { IsBusy = true; var RestApi = new RestApi(); var Result = await RestApi.GetActivity(); if (Result.Item1) { foreach (var item in DataStore.GetGlucosAsync().Where(i => i.Uploaded == true)) { DataStore.DeleteGlucose(item); } foreach (var item in DataStore.GetHb1acAsync().Where(i => i.Uploaded == true)) { DataStore.DeleteHb1Ac(item); } foreach (var item in DataStore.GetPressionAsync().Where(i => i.Uploaded == true)) { DataStore.DeletePression(item); } foreach (var item in DataStore.GetWeightAsync().Where(i => i.Uploaded == true)) { DataStore.DeleteWeight(item); } foreach (var item in JsonConvert.DeserializeObject <List <UploadData_Model> >(Result.Item2)) { if (item.type == "glucose") { var glucose = new Glucose_Model(); glucose.Activity = (item.activity.HasValue) ? (bool)item.activity : false; glucose.Taking_Medication = (item.took_medication.HasValue) ? (bool)item.activity : false; glucose.Date = item.date_taken; glucose.Glucose_time = item.period; glucose.Note = item.note; glucose.Glycemia = (double)item.value; glucose.Uploaded = true; DataStore.AddGlucose(glucose); } if (item.type == "hba1c") { var hb1ac = new Hb1Ac_Model(); hb1ac.Date = item.date_taken; hb1ac.Laboratory = item.laboratory; hb1ac.Note = item.note; hb1ac.Hb1Ac = (double)item.value; hb1ac.Uploaded = true; DataStore.AddHbaAc(hb1ac); } if (item.type == "weight") { var weight = new Weight_Model(); weight.Date = item.date_taken; weight.Note = item.note; weight.Weight = (double)item.value; weight.Uploaded = true; DataStore.AddWeight(weight); } if (item.type == "pressure") { var pressure = new Pression_Model(); pressure.Atrial_Fibrilation = (item.atrial_fibrilation.HasValue) ? (bool)item.activity : false; pressure.Date = item.date_taken; pressure.Where = item.place_taken; pressure.Note = item.note; pressure.Systolique = (item.systolic.HasValue) ? (int)item.systolic : 0; pressure.Diastolique = (item.diastolic.HasValue) ? (int)item.diastolic : 0; pressure.Heart_Freaquancy = (item.heart_frequency.HasValue) ? (int)item.heart_frequency : 0; pressure.Uploaded = true; DataStore.AddPression(pressure); } } UpdateData(); } else { DependencyService.Get <IMessage>().ShortAlert(Result.Item2); } IsBusy = false; }
public void DeleteWeight(Weight_Model data) { _connection.Delete(data); }
public void AddWeight(Weight_Model data) { _connection.Insert(data); }
public void UpdateWeight(Weight_Model data) { _connection.Update(data); }