private void AnimeFunction(int animeId) { while (true) { var animeObject = PageScraper.GetAnimeInfo(animeId); if (DatabaseControl.AnimeExists(animeId, false)) { DatabaseControl.InsertGenre(animeId, animeObject.Genre); DatabaseControl.InsertAnime(animeObject); if (animeObject.SequelID != 0) { if (DatabaseControl.AnimeExists((int)animeObject.SequelID, false)) { animeId = animeObject.SequelID.Value; continue; } if (animeObject.PrequelID != 0) { if (DatabaseControl.AnimeExists((int)animeObject.PrequelID, false)) { animeId = animeObject.PrequelID.Value; continue; } } } } else { var oldAnime = DatabaseControl.GetAnimeById(animeId); var updateAnime = new UpdateAnime { Aired = animeObject.Aired == oldAnime.Aired ? null : animeObject.Aired, Episodes = animeObject.Episodes == oldAnime.Episodes ? null : animeObject.Episodes, Status = animeObject.Status == oldAnime.Status ? null : animeObject.Status, Duration = animeObject.Duration == oldAnime.Duration ? null : animeObject.Duration, Rating = animeObject.Rating == oldAnime.Rating ? null : animeObject.Rating, Prequel = animeObject.Prequel == oldAnime.Prequel ? null : animeObject.Prequel, Sequel = animeObject.Sequel == oldAnime.Sequel ? null : animeObject.Sequel, ID = animeId }; if (updateAnime.Status != null || updateAnime.Aired != null || updateAnime.Duration != null || updateAnime.Rating != null || updateAnime.Prequel != null || updateAnime.Sequel != null || updateAnime.Episodes != null) { txtResults.Text += "\nAnimeID: " + animeId + "\n"; UpdateTxtResults(oldAnime, updateAnime); DatabaseControl.UpdateAnime(updateAnime); } } break; } }
private void RunAnime(IList <string> animeList) { var urlChecker = new UrlChecker(); var AnimeList = urlChecker.Check(animeList); foreach (var anime in AnimeList) { if (DatabaseControl.AnimeExists(anime.ID, false)) { DatabaseControl.InsertGenre(anime.ID, anime.Genre); DatabaseControl.InsertAnime(anime); } else { var oldAnime = DatabaseControl.GetAnimeById(anime.ID); var updateAnime = new UpdateAnime { Aired = anime.Aired == oldAnime.Aired ? null : anime.Aired, Episodes = anime.Episodes == oldAnime.Episodes ? null : anime.Episodes, Status = anime.Status == oldAnime.Status ? null : anime.Status, Duration = anime.Duration == oldAnime.Duration ? null : anime.Duration, Rating = anime.Rating == oldAnime.Rating ? null : anime.Rating, Prequel = anime.Prequel == oldAnime.Prequel ? null : anime.Prequel, Sequel = anime.Sequel == oldAnime.Sequel ? null : anime.Sequel, ID = anime.ID }; if (updateAnime.Status != null || updateAnime.Aired != null || updateAnime.Duration != null || updateAnime.Rating != null || updateAnime.Prequel != null || updateAnime.Sequel != null || updateAnime.Episodes != null) { txtResults.Text += "\nAnimeID: " + anime.ID + "\n"; UpdateTxtResults(oldAnime, updateAnime); DatabaseControl.UpdateAnime(updateAnime); } } } }
public static void UpdateAnime(UpdateAnime anime) => Connection.Execute("UpdateAnime", anime, commandType: CommandType.StoredProcedure);