コード例 #1
0
ファイル: FavPageModel.cs プロジェクト: maherzaidoune/be4care
        private async Task <IList <HealthStruct> > GetHealthStructs()
        {
            try
            {
                var docs = await _hStructServices.GetStructs();

                if (docs == null || docs.Count == 0)
                {
                    docs = await _restServices.GetHealthStructs();
                }
                return(docs);
            }
            catch
            {
                return(null);
            }
        }
コード例 #2
0
        private async Task <IList <HealthStruct> > GetHealthStructs()
        {
            try
            {
                var healthStructs = await _hStructServices.GetStructs();

                if (healthStructs == null || healthStructs.Count == 0)
                {
                    healthStructs = await _restServices.GetHealthStructs();

                    if (healthStructs != null && healthStructs.Count > 0)
                    {
                        _hStructServices.SaveStructs(healthStructs);
                    }
                    else
                    {
                        healthStructs = new List <HealthStruct>();
                    }
                }
                return(healthStructs);
            }
            catch
            {
                var healthStructs = await _restServices.GetHealthStructs();

                if (healthStructs != null && healthStructs.Count > 0)
                {
                    _hStructServices.SaveStructs(healthStructs);
                }
                else
                {
                    healthStructs = new List <HealthStruct>();
                }
                return(healthStructs);
            }
        }
コード例 #3
0
        public async Task UpdateList()
        {
            try
            {
                userstruct = await _hStructServices.GetStructs();

                if (userstruct == null || userstruct.Count == 0)
                {
                    userstruct = new List <HealthStruct>();
                }
            }
            catch
            {
                Console.WriteLine("can't get user doctor list");
                userstruct = null;
            }
            try
            {
                var docs = await _hStructServices.GetAllHstrcts();

                if (docs == null)
                {
                    docs = await _restServices.GetAllHstruct();

                    _hStructServices.saveAllHstruct(docs);
                }

                foreach (HealthStruct d in docs)
                {
                    if (userstruct != null && userstruct.Count > 0)
                    {
                        if (alreadyAdded(d, userstruct))
                        {
                            structs.Add(new hList {
                                add = false, hstruct = d, fullName = d.fullName
                            });
                        }
                        else
                        {
                            structs.Add(new hList {
                                add = true, hstruct = d, fullName = d.fullName
                            });
                        }
                    }
                    else
                    {
                        structs.Add(new hList {
                            add = true, hstruct = d, fullName = d.fullName
                        });
                    }
                }
            }
            catch
            {
                Console.WriteLine("error getting structs from local database");
                var docs = await _restServices.GetAllHstruct();

                if (_hStructServices.saveAllHstruct(docs))
                {
                    Console.WriteLine("Doctors  saved");
                }
                foreach (HealthStruct d in docs)
                {
                    foreach (HealthStruct ud in userstruct)
                    {
                        if (d.id == ud.id)
                        {
                            structs.Add(new hList {
                                add = false, hstruct = d, fullName = d.fullName
                            });
                            break;
                        }
                    }
                    structs.Add(new hList {
                        add = true, hstruct = d, fullName = d.fullName
                    });
                }
            }
            isBusy    = false;
            isEnabled = true;
            list      = structs;
        }