Esempio n. 1
0
 public int AddEntries(List<AnimeEntry> entries)
 {
     using (var dbContext = new AnimeTempEntities())
     {
         foreach (var entry in entries)
         {
             var dbObj = AutoMapper.Mapper.Map<Anime>(entry);
             dbObj.DataUpdatedDate = DateTime.Now;
             dbContext.Animes.Add(dbObj);
             dbContext.SaveChanges();
         }
         return entries.Count;
     }
 }
Esempio n. 2
0
        public string AddNewSearchTerm(string searchTerm)
        {
            using (var dbContext = new AnimeTempEntities())
            {
                var existing = dbContext.AnimeHomes.Any(x => x.AnimeTitle == searchTerm.Trim());
                if (existing)
                    return searchTerm + " already in db";

                dbContext.AnimeHomes.Add(new AnimeHome()
                {
                    AnimeTitle = searchTerm,
                    downloaded = false,
                });
                dbContext.SaveChanges();

               return searchTerm   + " saved";

            }
        }
Esempio n. 3
0
 public void UpdateSynopsisFileLastGenerated(int id, DateTime date)
 {
     using (var dbContext = new AnimeTempEntities())
     {
         var dbObj = dbContext.Animes.First(x => x.Id == id);
         dbObj.SynopsisFileLastGenerated = DateTime.Now;
         dbContext.SaveChanges();
     }
 }
Esempio n. 4
0
        public void UpdateDetails(AnimeEntry anime)
        {
            using (var dbContext = new AnimeTempEntities())
            {
                //var dbObjs = dbContext.Animes.Where(x => x.DataUpdatedDate == null).ToList();

                var dbObj = dbContext.Animes.First(x => x.Id == anime.Id);
                AutoMapper.Mapper.Map(anime, dbObj);
                dbObj.DataUpdatedDate = DateTime.Now;
                dbContext.SaveChanges();
            }
        }
Esempio n. 5
0
 public void MarkQueryDownloaded(string query)
 {
     using (var dbContext = new AnimeTempEntities())
     {
         var dbObjs = dbContext.AnimeHomes.Where(x => x.AnimeTitle == query).ToList();
         foreach (var obj in dbObjs)
         {
             obj.downloaded = true;
         }
         dbContext.SaveChanges();
     }
 }
Esempio n. 6
0
 public string MarkForDataUpdate(int id)
 {
     using (var dbContext = new AnimeTempEntities())
     {
         var dbObj = dbContext.Animes.First(x => x.Id == id);
         dbObj.SynopsisFileLastGenerated = null;
         dbObj.DataUpdatedDate = null;
         dbContext.SaveChanges();
         return  id + " flag set for refresh";
     }
 }