Пример #1
0
        public async Task <IList <Document> > GetDocuments()
        {
            var docs = await _documentSerives.GetDocuments();

            try
            {
                if (docs == null || docs.Count == 0)
                {
                    docs = await _restServices.GetDocumentsAsync();

                    if (!(docs == null || docs.Count == 0))
                    {
                        _documentSerives.SaveDocuments(docs);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch
            {
                docs = await _restServices.GetDocumentsAsync();

                if (!(docs == null || docs.Count == 0))
                {
                    _documentSerives.SaveDocuments(docs);
                }
                else
                {
                    return(null);
                }
            }
            return(docs);
        }
Пример #2
0
 public async Task UpdateView()
 {
     documents = new List <Document>();
     await Task.Run(async() => {
         try
         {
             documents = await _documentSerives.GetDocuments();
             if (documents == null || documents.Count == 0)
             {
                 documents = await _restServices.GetDocumentsAsync();
                 if (!(documents == null || documents.Count == 0))
                 {
                     _documentSerives.SaveDocuments(documents);
                 }
             }
             MessagingCenter.Send(this, "DocumentareUpdated");
         }
         catch
         {
             Console.WriteLine("error getting documents from local database");
             documents = await _restServices.GetDocumentsAsync();
             if (!(documents == null || documents.Count == 0))
             {
                 _documentSerives.SaveDocuments(documents);
             }
         }
         InitGroups(tri);
     });
 }