Esempio n. 1
0
        public async Task UpdateLiveMedicineList()
        {
            var list = await _cacheService.GetListOnCache();

            List <MedicineItemGroupedModel> orderedList = new List <MedicineItemGroupedModel>();

            if (list != null)
            {
                list.ForEach(y =>
                {
                    var newGroup = new MedicineItemGroupedModel();
                    y.OrderBy(z => z.IlacTarihi.date).ForEach(item =>
                    {
                        newGroup.Add(item);
                        newGroup.Date = item.IlacTarihi.date;
                        if (EquelsNowMinute(newGroup.Date) && haveScrollAction)
                        {
                            currentlyItems.Add(item);
                            CurrentMedicineAction?.Invoke(item);
                            haveScrollAction = false;
                        }
                    });
                    orderedList.Add(newGroup);
                });
            }
            if (orderedList != null && orderedList.Any())
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    LiveMedicineList = new ObservableCollection <MedicineItemGroupedModel>(orderedList.OrderBy(x => x.Date));
                });
            }
        }
Esempio n. 2
0
 public async Task FetchMedicineList()
 {
     IsBusy           = true;
     haveScrollAction = true;
     if (Connectivity.NetworkAccess == NetworkAccess.Internet)
     {
         Device.BeginInvokeOnMainThread(async() =>
         {
             var response = await _api.GetList();
             if (!response.isError)
             {
                 var listData = response.value;
                 MedicineList = new ObservableCollection <MedicineItemGroupedModel>();
                 listData.GroupBy(x => x.IlacTarihi.date.Date).ForEach((y) =>
                 {
                     var group = new MedicineItemGroupedModel()
                     {
                         Date = y.Key
                     };
                     y.ForEach((m) =>
                     {
                         group.Add(m);
                     });
                     MedicineList.Add(group);
                 });
                 if (MedicineList != null)
                 {
                     _cacheService.SaveDataItems(MedicineList.OrderBy(x => x.Date));
                 }
             }
             else
             {
                 //return err msg...
             }
             IsBusy = false;
         });
     }
     else
     {
         IsBusy = false;
     }
 }