public static void AddSeriesVote(HttpContext context, SVR_AnimeSeries ser, int userID, Vote vote) { int voteType = (vote.Type?.ToLowerInvariant() ?? "") switch { "temporary" => (int)AniDBVoteType.AnimeTemp, "permanent" => (int)AniDBVoteType.Anime, _ => ser.GetAnime()?.GetFinishedAiring() ?? false ? (int)AniDBVoteType.Anime : (int)AniDBVoteType.AnimeTemp, }; AniDB_Vote dbVote = RepoFactory.AniDB_Vote.GetByEntityAndType(ser.AniDB_ID, AniDBVoteType.AnimeTemp) ?? RepoFactory.AniDB_Vote.GetByEntityAndType(ser.AniDB_ID, AniDBVoteType.Anime); if (dbVote == null) { dbVote = new AniDB_Vote { EntityID = ser.AniDB_ID, }; } dbVote.VoteValue = (int)Math.Floor(vote.GetRating(1000)); dbVote.VoteType = voteType; RepoFactory.AniDB_Vote.Save(dbVote); var cmdVote = new CommandRequest_VoteAnime(ser.AniDB_ID, voteType, vote.GetRating()); cmdVote.Save(); }
public static void AddEpisodeVote(HttpContext context, SVR_AnimeEpisode ep, int userID, Vote vote) { AniDB_Vote dbVote = RepoFactory.AniDB_Vote.GetByEntityAndType(ep.AnimeEpisodeID, AniDBVoteType.Episode); if (dbVote == null) { dbVote = new AniDB_Vote { EntityID = ep.AnimeEpisodeID, VoteType = (int)AniDBVoteType.Episode, }; } dbVote.VoteValue = (int)Math.Floor(vote.GetRating(1000)); RepoFactory.AniDB_Vote.Save(dbVote); //var cmdVote = new CommandRequest_VoteAnimeEpisode(ep.AniDB_EpisodeID, voteType, vote.GetRating()); //cmdVote.Save(); }