protected SqliteCommand GetUpdateSeriesSequenceCommand(SqliteConnection db, SeriesSequence sequence, string idColumn, object idValue) { var command = new SqliteCommand($"UPDATE series_sequence SET is_season = {sequence.IsSeason}, season_number = {sequence.SeasonNumber} WHERE {idColumn} = @UniqueId", db); command.Parameters.AddWithValue("@UniqueId", idValue); return(command); }
public void UpsertSeriesSequences_ShouldInsertNewItems() { var sequences = new List <ExportedSeriesSequenceSimpleDto>(); for (int i = 0; i < 3; ++i) { var s = new SeriesSequence(-1, "t" + i, "", -1, false, false, 0, testSeries.SeriesId, UniqueIdUtil.GenerateUniqueId()); sequences.Add(new ExportedSeriesSequenceSimpleDto(s, null, testSeries.UniqueId)); } var ids = new Dictionary <string, long>(); repository.UpsertSeriesSequences(sequences, ids); var retSequences = repository.GetVideoSequencesInSeries(testSeries.SeriesId, GetFirstPage()).Result.Results; var expectedIds = new Dictionary <string, long>(); foreach (var s in retSequences) { expectedIds[s.UniqueId] = s.SequenceId; } var expectedSequences = sequences.Select(p => p.Details).ToList(); CollectionAssert.AreEquivalent(expectedSequences, retSequences); CollectionAssert.AreEquivalent(expectedIds, ids); }
public async Task <PaginationResult <Video> > GetVideosNotInSeriesSequence(SeriesSequence sequence, long seriesId, string titleFilter, Pagination pagination) { var videosToExcludeQuery = sequence.IsSeason ? ($"SELECT vs.video_id FROM video_in_sequence vs, series_sequence ss WHERE vs.sequence_id = ss.sequence_id AND ss.series_id = {seriesId} AND ss.is_season = true AND ss.deleted = false") : ($"SELECT vs.video_id FROM video_in_sequence vs WHERE vs.sequence_id = {sequence.SequenceId}"); var query = $"{SELECT_BASE} WHERE v.deleted = false AND v.title LIKE @TitleFilter AND v.series_id = {seriesId} AND v.video_id NOT IN ({videosToExcludeQuery})"; Action <SqliteCommand> parameterize = (SqliteCommand command) => { command.Parameters.AddWithValue("@TitleFilter", "%" + titleFilter + "%"); }; return(await DataAccessUtil.GetPaginatedResult(pagination, query, parameterize, ParseVideo)); }
public ExportedSeriesSequenceSimpleDto(SeriesSequence details, string fileId, string seriesId) { Details = details; FileId = fileId; SeriesId = seriesId; }