Ejemplo n.º 1
0
        public async Task <IEnumerable <CalendarTable> > GetCalendarAsync()
        {
            if (!initialized)
            {
                Init();
            }
            List <CalendarTable> calendarTables = new List <CalendarTable>();

            try
            {
                IFolder folder = await rootFolder.CreateFolderAsync("Library", CreationCollisionOption.OpenIfExists);

                // create a file, overwriting any existing fileMySubFolder
                IFile Calendarfile = await folder.CreateFileAsync("Calendar.json", CreationCollisionOption.OpenIfExists);

                var json = await Calendarfile.ReadAllTextAsync();

                // populate the file with some text
                CalendarTable = JsonConvert.DeserializeObject <CalendarInfo.RootObject>(json);
                if (CalendarTable.items != null)
                {
                    foreach (var item in CalendarTable.items)
                    {
                        CalendarTable calendar = new CalendarTable(item);
                        calendarTables.Add(calendar);
                    }
                }
            }
            catch (Exception)
            {
            }
            return(await Task.Run(() => calendarTables));

            //sqlite.GetCalendarItems());
        }
Ejemplo n.º 2
0
 public Task AddCalendarItems(CalendarInfo.RootObject rootObject)
 {
     if (rootObject.items.Count > 100)
     {
         _connection.DeleteAll <CalendarTable>();
     }
     foreach (var items in rootObject.items)
     {
         if (items != null)
         {
             var Citem = new CalendarTable(items);
             {
                 if (!_connection.Table <CalendarTable>().Any(x => x.id == Citem.id))
                 {
                     _connection.Insert(Citem);
                 }
                 else
                 {
                     _connection.Update(Citem);
                 }
             }
         }
     }
     return(Task.Run(() => rootObject));
 }