示例#1
0
        public AddDrugs_ViewModel(INavigation navigation, IDataStore dataStore, Drugs_Model drug = null)
        {
            DataStore         = dataStore;
            Navigation        = navigation;
            Taking_Times_List = new List <string>();
            Taking_Times_List.Add(Resources["Unimportant"]);
            Taking_Times_List.Add(Resources["Without food"]);
            Taking_Times_List.Add(Resources["Before_Meal"]);
            Taking_Times_List.Add(Resources["After_Meals"]);
            if (drug != null)
            {
                Drugs       = drug;
                Times_List  = new ObservableCollection <string>(Drugs.Times_List);
                PicturePath = Drugs.PicturePathe;
                Picture     = ImageSource.FromFile(PicturePath);
                IsVisible   = true;
            }
            else
            {
                Drugs      = new Drugs_Model();
                Times_List = new ObservableCollection <string>();
            }
            string JsonFile = "DrugsJson.json";
            var    assembly = IntrospectionExtensions.GetTypeInfo(typeof(AddDrugs_ViewModel)).Assembly;
            Stream stream   = assembly.GetManifestResourceStream($"{assembly.GetName().Name}.{JsonFile}");

            using (var reader = new StreamReader(stream))
            {
                var json = reader.ReadToEnd();
                DrugsList = JsonConvert.DeserializeObject <List <DrugsJsonModel> >(json).Select(i => i.Name).ToList();
            }
            PermissionsRequest = new PermissionsRequest();
            MessagingCenter.Subscribe <AddDrugs_View, string>(this, "AddDrugs", (sender, args) =>
            {
                Times_List.Add(args);
            });
            SaveCommand = new Command(async() =>
            {
                await ExecuteOnSave();
            });
            TakePictureCommand = new Command(async() =>
            {
                await ExecuteOnTakePicture();
            });
            PictureTappedCommand = new Command(async() =>
            {
                await ExecuteOnPictureTapped();
            });
            DeleteCommand = new Command(async() =>
            {
                await ExecuteOnDelete();
            });
            EditCommand = new Command(async() =>
            {
                await ExecuteOnEdit();
            });
        }
        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();
            });
        }
示例#3
0
 public void DeleteDrugs(Drugs_Model data)
 {
     _connection.Delete(data);
 }
示例#4
0
 public void AddDrugs(Drugs_Model data)
 {
     _connection.Insert(data);
 }
示例#5
0
 public void UpdateDrugs(Drugs_Model data)
 {
     _connection.Update(data);
 }