Beispiel #1
0
        public async Task Init()
        {
            var items = await storage.List <MedicationDosage>();

            if (items != null)
            {
                MedicationList = items;
            }
            else
            {
                MedicationList = new List <MedicationDosage>();
            }
        }
Beispiel #2
0
        public async Task reloadDataBase()
        {
            IPermanentStorageService storage       = Mvx.Resolve <IPermanentStorageService>();
            INotificationService     notifications = Mvx.Resolve <INotificationService>();
            var items = await storage.List <MedicationDosage>();

            if (items == null)
            {
                return;
            }
            var medicationList = new List <MedicationDosage>(items);

            foreach (var item in medicationList)
            {
                var dosageHours = new List <TimeSpan>();
                var hours       = item.Hours.Split(new string[] { ", " }, StringSplitOptions.None);

                dosageHours = HoursList
                              .Where(h => hours.Contains(h.Name))
                              .Select(i => i.Hour)
                              .ToList();

                if (dosageHours.Count > 0)
                {
                    item.DosageHours = dosageHours;
                    item.RingUri     = ringUri;

                    // szud bi in som separet entity
                    await notifications.CancelAllNotificationsForMedication(item);

                    await storage.SaveAsync <MedicationDosage>(item);

                    await DbHelper.AddNotificationOccurrences(item);

                    await notifications.ScheduleNotifications(item);
                }
            }
        }