Ejemplo n.º 1
0
 internal Episode GetEpisode()
 {
     using (var db = new LocalStorageContext())
     {
         return(db.EpisodeCache.Where(ep => ep.Id == this.EpisodeId).FirstOrDefault());
     }
 }
Ejemplo n.º 2
0
 public static void CheckMigrations()
 {
     _initializer.CheckInitialized();
     using (var db = new LocalStorageContext())
     {
         db.Database.Migrate();
     }
 }
Ejemplo n.º 3
0
        internal async Task RemoveTopThreeItems()
        {
            using (var db = new LocalStorageContext())
            {
                var episodes = await GetEpisodes();

                db.EpisodeCache.Remove(episodes[0]);
                db.EpisodeCache.Remove(episodes[1]);
                db.EpisodeCache.Remove(episodes[2]);
                await db.SaveChangesAsync();
            }
        }
Ejemplo n.º 4
0
        public async Task <List <Episode> > GetEpisodes()
        {
            using (var db = new LocalStorageContext())
            {
                var cached = db.EpisodeCache.Where(i => i.FeedId == this.Uri.ToString())
                             .OrderByDescending(ob => ob.PublishDate);
                if (cached.Count() > 0)
                {
                    foreach (var item in cached)
                    {
                        item.Feed = this;
                    }

                    return(cached.ToList());
                }
            }

            return(await GetNewEpisodesAsync());
        }
Ejemplo n.º 5
0
        internal async Task <List <Episode> > GetNewEpisodesAsync()
        {
            List <Episode> newEpisodes = new List <Episode>();
            var            results     = await GetEpisodesInternalAsync();

            using (var db = new LocalStorageContext())
            {
                foreach (var item in results)
                {
                    if (db.EpisodeCache.Where(i => (i.Key == item.Key && i.Feed == item.Feed)).Count() == 0)
                    {
                        db.EpisodeCache.Add(item);
                        newEpisodes.Add(item);
                    }
                }

                db.SaveChanges();
            }

            return(newEpisodes);
        }