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