예제 #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;
     }
 }
예제 #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";

            }
        }
예제 #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();
     }
 }
예제 #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();
            }
        }
예제 #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();
     }
 }
예제 #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";
     }
 }