mirror of https://github.com/ErsatzTV/ErsatzTV.git
44 changed files with 3639 additions and 179 deletions
@ -0,0 +1,7 @@
@@ -0,0 +1,7 @@
|
||||
using System.Collections.Generic; |
||||
using MediatR; |
||||
|
||||
namespace ErsatzTV.Application.Television.Queries |
||||
{ |
||||
public record GetAllTelevisionSeasons : IRequest<List<TelevisionSeasonViewModel>>; |
||||
} |
||||
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Threading; |
||||
using System.Threading.Tasks; |
||||
using ErsatzTV.Core.Interfaces.Repositories; |
||||
using LanguageExt; |
||||
using MediatR; |
||||
using static ErsatzTV.Application.Television.Mapper; |
||||
|
||||
namespace ErsatzTV.Application.Television.Queries |
||||
{ |
||||
public class |
||||
GetAllTelevisionSeasonsHandler : IRequestHandler<GetAllTelevisionSeasons, List<TelevisionSeasonViewModel>> |
||||
{ |
||||
private readonly ITelevisionRepository _televisionRepository; |
||||
|
||||
public GetAllTelevisionSeasonsHandler(ITelevisionRepository televisionRepository) => |
||||
_televisionRepository = televisionRepository; |
||||
|
||||
public Task<List<TelevisionSeasonViewModel>> Handle( |
||||
GetAllTelevisionSeasons request, |
||||
CancellationToken cancellationToken) => |
||||
_televisionRepository.GetAllSeasons().Map(list => list.Map(ProjectToViewModel).ToList()); |
||||
} |
||||
} |
||||
@ -0,0 +1,7 @@
@@ -0,0 +1,7 @@
|
||||
using System.Collections.Generic; |
||||
using MediatR; |
||||
|
||||
namespace ErsatzTV.Application.Television.Queries |
||||
{ |
||||
public record GetAllTelevisionShows : IRequest<List<TelevisionShowViewModel>>; |
||||
} |
||||
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Threading; |
||||
using System.Threading.Tasks; |
||||
using ErsatzTV.Core.Interfaces.Repositories; |
||||
using LanguageExt; |
||||
using MediatR; |
||||
using static ErsatzTV.Application.Television.Mapper; |
||||
|
||||
namespace ErsatzTV.Application.Television.Queries |
||||
{ |
||||
public class GetAllTelevisionShowsHandler : IRequestHandler<GetAllTelevisionShows, List<TelevisionShowViewModel>> |
||||
{ |
||||
private readonly ITelevisionRepository _televisionRepository; |
||||
|
||||
public GetAllTelevisionShowsHandler(ITelevisionRepository televisionRepository) => |
||||
_televisionRepository = televisionRepository; |
||||
|
||||
public Task<List<TelevisionShowViewModel>> Handle( |
||||
GetAllTelevisionShows request, |
||||
CancellationToken cancellationToken) => |
||||
_televisionRepository.GetAllShows().Map(list => list.Map(ProjectToViewModel).ToList()); |
||||
} |
||||
} |
||||
@ -1,4 +1,4 @@
@@ -1,4 +1,4 @@
|
||||
namespace ErsatzTV.Application.Television |
||||
{ |
||||
public record TelevisionSeasonViewModel(int ShowId, string Title, string Year, string Plot, string Poster); |
||||
public record TelevisionSeasonViewModel(int Id, int ShowId, string Title, string Year, string Plot, string Poster); |
||||
} |
||||
|
||||
@ -1,4 +1,4 @@
@@ -1,4 +1,4 @@
|
||||
namespace ErsatzTV.Application.Television |
||||
{ |
||||
public record TelevisionShowViewModel(string Title, string Year, string Plot, string Poster); |
||||
public record TelevisionShowViewModel(int Id, string Title, string Year, string Plot, string Poster); |
||||
} |
||||
|
||||
@ -0,0 +1,78 @@
@@ -0,0 +1,78 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Threading.Tasks; |
||||
using ErsatzTV.Core.Domain; |
||||
using ErsatzTV.Core.Interfaces.Repositories; |
||||
using LanguageExt; |
||||
|
||||
namespace ErsatzTV.Core.Tests.Fakes |
||||
{ |
||||
public class FakeTelevisionRepository : ITelevisionRepository |
||||
{ |
||||
public Task<bool> Update(TelevisionShow show) => throw new NotSupportedException(); |
||||
|
||||
public Task<bool> Update(TelevisionSeason season) => throw new NotSupportedException(); |
||||
|
||||
public Task<bool> Update(TelevisionEpisodeMediaItem episode) => throw new NotSupportedException(); |
||||
|
||||
public Task<List<TelevisionShow>> GetAllShows() => throw new NotSupportedException(); |
||||
|
||||
public Task<Option<TelevisionShow>> GetShow(int televisionShowId) => throw new NotSupportedException(); |
||||
|
||||
public Task<int> GetShowCount() => throw new NotSupportedException(); |
||||
|
||||
public Task<List<TelevisionShow>> GetPagedShows(int pageNumber, int pageSize) => |
||||
throw new NotSupportedException(); |
||||
|
||||
public Task<List<TelevisionEpisodeMediaItem>> GetShowItems(int televisionShowId) => |
||||
throw new NotSupportedException(); |
||||
|
||||
public Task<List<TelevisionSeason>> GetAllSeasons() => throw new NotSupportedException(); |
||||
|
||||
public Task<Option<TelevisionSeason>> GetSeason(int televisionSeasonId) => throw new NotSupportedException(); |
||||
|
||||
public Task<int> GetSeasonCount(int televisionShowId) => throw new NotSupportedException(); |
||||
|
||||
public Task<List<TelevisionSeason>> GetPagedSeasons(int televisionShowId, int pageNumber, int pageSize) => |
||||
throw new NotSupportedException(); |
||||
|
||||
public Task<List<TelevisionEpisodeMediaItem>> GetSeasonItems(int televisionSeasonId) => |
||||
throw new NotSupportedException(); |
||||
|
||||
public Task<Option<TelevisionEpisodeMediaItem>> GetEpisode(int televisionEpisodeId) => |
||||
throw new NotSupportedException(); |
||||
|
||||
public Task<int> GetEpisodeCount(int televisionSeasonId) => throw new NotSupportedException(); |
||||
|
||||
public Task<List<TelevisionEpisodeMediaItem>> GetPagedEpisodes( |
||||
int televisionSeasonId, |
||||
int pageNumber, |
||||
int pageSize) => throw new NotSupportedException(); |
||||
|
||||
public Task<Option<TelevisionShow>> GetShowByPath(int mediaSourceId, string path) => |
||||
throw new NotSupportedException(); |
||||
|
||||
public Task<Option<TelevisionShow>> GetShowByMetadata(TelevisionShowMetadata metadata) => |
||||
throw new NotSupportedException(); |
||||
|
||||
public Task<Either<BaseError, TelevisionShow>> AddShow( |
||||
int localMediaSourceId, |
||||
string showFolder, |
||||
TelevisionShowMetadata metadata) => throw new NotSupportedException(); |
||||
|
||||
public Task<Either<BaseError, TelevisionSeason>> GetOrAddSeason( |
||||
TelevisionShow show, |
||||
string path, |
||||
int seasonNumber) => throw new NotSupportedException(); |
||||
|
||||
public Task<Either<BaseError, TelevisionEpisodeMediaItem>> GetOrAddEpisode( |
||||
TelevisionSeason season, |
||||
int mediaSourceId, |
||||
string path) => throw new NotSupportedException(); |
||||
|
||||
public Task<Unit> DeleteMissingSources(int localMediaSourceId, List<string> allFolders) => |
||||
throw new NotSupportedException(); |
||||
|
||||
public Task<Unit> DeleteEmptyShows() => throw new NotSupportedException(); |
||||
} |
||||
} |
||||
@ -0,0 +1,9 @@
@@ -0,0 +1,9 @@
|
||||
namespace ErsatzTV.Core.Domain |
||||
{ |
||||
public enum ProgramScheduleItemCollectionType |
||||
{ |
||||
Collection = 0, |
||||
TelevisionShow = 1, |
||||
TelevisionSeason = 2 |
||||
} |
||||
} |
||||
@ -0,0 +1,9 @@
@@ -0,0 +1,9 @@
|
||||
using ErsatzTV.Core.Domain; |
||||
|
||||
namespace ErsatzTV.Core.Scheduling |
||||
{ |
||||
public class TelevisionSeasonMediaCollection : MediaCollection |
||||
{ |
||||
public int TelevisionSeasonId { get; set; } |
||||
} |
||||
} |
||||
@ -0,0 +1,9 @@
@@ -0,0 +1,9 @@
|
||||
using ErsatzTV.Core.Domain; |
||||
|
||||
namespace ErsatzTV.Core.Scheduling |
||||
{ |
||||
public class TelevisionShowMediaCollection : MediaCollection |
||||
{ |
||||
public int TelevisionShowId { get; set; } |
||||
} |
||||
} |
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,209 @@
@@ -0,0 +1,209 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
||||
namespace ErsatzTV.Infrastructure.Migrations |
||||
{ |
||||
public partial class ScheduleCollectionTypes : Migration |
||||
{ |
||||
protected override void Up(MigrationBuilder migrationBuilder) |
||||
{ |
||||
migrationBuilder.DropForeignKey( |
||||
"FK_PlayoutProgramScheduleItemAnchors_MediaCollections_MediaCollectionId", |
||||
"PlayoutProgramScheduleItemAnchors"); |
||||
|
||||
migrationBuilder.DropForeignKey( |
||||
"FK_ProgramScheduleItems_MediaCollections_MediaCollectionId", |
||||
"ProgramScheduleItems"); |
||||
|
||||
migrationBuilder.DropPrimaryKey( |
||||
"PK_PlayoutProgramScheduleItemAnchors", |
||||
"PlayoutProgramScheduleItemAnchors"); |
||||
|
||||
migrationBuilder.DropIndex( |
||||
"IX_PlayoutProgramScheduleItemAnchors_MediaCollectionId", |
||||
"PlayoutProgramScheduleItemAnchors"); |
||||
|
||||
migrationBuilder.RenameColumn( |
||||
"MediaCollectionId", |
||||
"PlayoutProgramScheduleItemAnchors", |
||||
"CollectionType"); |
||||
|
||||
migrationBuilder.AlterColumn<int>( |
||||
"MediaCollectionId", |
||||
"ProgramScheduleItems", |
||||
"INTEGER", |
||||
nullable: true, |
||||
oldClrType: typeof(int), |
||||
oldType: "INTEGER"); |
||||
|
||||
migrationBuilder.AddColumn<int>( |
||||
"CollectionType", |
||||
"ProgramScheduleItems", |
||||
"INTEGER", |
||||
nullable: false, |
||||
defaultValue: 0); |
||||
|
||||
migrationBuilder.AddColumn<int>( |
||||
"TelevisionSeasonId", |
||||
"ProgramScheduleItems", |
||||
"INTEGER", |
||||
nullable: true); |
||||
|
||||
migrationBuilder.AddColumn<int>( |
||||
"TelevisionShowId", |
||||
"ProgramScheduleItems", |
||||
"INTEGER", |
||||
nullable: true); |
||||
|
||||
migrationBuilder.AddColumn<int>( |
||||
"Id", |
||||
"PlayoutProgramScheduleItemAnchors", |
||||
"INTEGER", |
||||
nullable: false, |
||||
defaultValue: 0) |
||||
.Annotation("Sqlite:Autoincrement", true); |
||||
|
||||
migrationBuilder.AddColumn<int>( |
||||
"CollectionId", |
||||
"PlayoutProgramScheduleItemAnchors", |
||||
"INTEGER", |
||||
nullable: false, |
||||
defaultValue: 0); |
||||
|
||||
migrationBuilder.AddPrimaryKey( |
||||
"PK_PlayoutProgramScheduleItemAnchors", |
||||
"PlayoutProgramScheduleItemAnchors", |
||||
"Id"); |
||||
|
||||
migrationBuilder.CreateIndex( |
||||
"IX_ProgramScheduleItems_TelevisionSeasonId", |
||||
"ProgramScheduleItems", |
||||
"TelevisionSeasonId"); |
||||
|
||||
migrationBuilder.CreateIndex( |
||||
"IX_ProgramScheduleItems_TelevisionShowId", |
||||
"ProgramScheduleItems", |
||||
"TelevisionShowId"); |
||||
|
||||
migrationBuilder.CreateIndex( |
||||
"IX_PlayoutProgramScheduleItemAnchors_PlayoutId", |
||||
"PlayoutProgramScheduleItemAnchors", |
||||
"PlayoutId"); |
||||
|
||||
migrationBuilder.AddForeignKey( |
||||
"FK_ProgramScheduleItems_MediaCollections_MediaCollectionId", |
||||
"ProgramScheduleItems", |
||||
"MediaCollectionId", |
||||
"MediaCollections", |
||||
principalColumn: "Id", |
||||
onDelete: ReferentialAction.Restrict); |
||||
|
||||
migrationBuilder.AddForeignKey( |
||||
"FK_ProgramScheduleItems_TelevisionSeasons_TelevisionSeasonId", |
||||
"ProgramScheduleItems", |
||||
"TelevisionSeasonId", |
||||
"TelevisionSeasons", |
||||
principalColumn: "Id", |
||||
onDelete: ReferentialAction.Restrict); |
||||
|
||||
migrationBuilder.AddForeignKey( |
||||
"FK_ProgramScheduleItems_TelevisionShows_TelevisionShowId", |
||||
"ProgramScheduleItems", |
||||
"TelevisionShowId", |
||||
"TelevisionShows", |
||||
principalColumn: "Id", |
||||
onDelete: ReferentialAction.Restrict); |
||||
} |
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder) |
||||
{ |
||||
migrationBuilder.DropForeignKey( |
||||
"FK_ProgramScheduleItems_MediaCollections_MediaCollectionId", |
||||
"ProgramScheduleItems"); |
||||
|
||||
migrationBuilder.DropForeignKey( |
||||
"FK_ProgramScheduleItems_TelevisionSeasons_TelevisionSeasonId", |
||||
"ProgramScheduleItems"); |
||||
|
||||
migrationBuilder.DropForeignKey( |
||||
"FK_ProgramScheduleItems_TelevisionShows_TelevisionShowId", |
||||
"ProgramScheduleItems"); |
||||
|
||||
migrationBuilder.DropIndex( |
||||
"IX_ProgramScheduleItems_TelevisionSeasonId", |
||||
"ProgramScheduleItems"); |
||||
|
||||
migrationBuilder.DropIndex( |
||||
"IX_ProgramScheduleItems_TelevisionShowId", |
||||
"ProgramScheduleItems"); |
||||
|
||||
migrationBuilder.DropPrimaryKey( |
||||
"PK_PlayoutProgramScheduleItemAnchors", |
||||
"PlayoutProgramScheduleItemAnchors"); |
||||
|
||||
migrationBuilder.DropIndex( |
||||
"IX_PlayoutProgramScheduleItemAnchors_PlayoutId", |
||||
"PlayoutProgramScheduleItemAnchors"); |
||||
|
||||
migrationBuilder.DropColumn( |
||||
"CollectionType", |
||||
"ProgramScheduleItems"); |
||||
|
||||
migrationBuilder.DropColumn( |
||||
"TelevisionSeasonId", |
||||
"ProgramScheduleItems"); |
||||
|
||||
migrationBuilder.DropColumn( |
||||
"TelevisionShowId", |
||||
"ProgramScheduleItems"); |
||||
|
||||
migrationBuilder.DropColumn( |
||||
"Id", |
||||
"PlayoutProgramScheduleItemAnchors"); |
||||
|
||||
migrationBuilder.DropColumn( |
||||
"CollectionId", |
||||
"PlayoutProgramScheduleItemAnchors"); |
||||
|
||||
migrationBuilder.RenameColumn( |
||||
"CollectionType", |
||||
"PlayoutProgramScheduleItemAnchors", |
||||
"MediaCollectionId"); |
||||
|
||||
migrationBuilder.AlterColumn<int>( |
||||
"MediaCollectionId", |
||||
"ProgramScheduleItems", |
||||
"INTEGER", |
||||
nullable: false, |
||||
defaultValue: 0, |
||||
oldClrType: typeof(int), |
||||
oldType: "INTEGER", |
||||
oldNullable: true); |
||||
|
||||
migrationBuilder.AddPrimaryKey( |
||||
"PK_PlayoutProgramScheduleItemAnchors", |
||||
"PlayoutProgramScheduleItemAnchors", |
||||
new[] { "PlayoutId", "ProgramScheduleId", "MediaCollectionId" }); |
||||
|
||||
migrationBuilder.CreateIndex( |
||||
"IX_PlayoutProgramScheduleItemAnchors_MediaCollectionId", |
||||
"PlayoutProgramScheduleItemAnchors", |
||||
"MediaCollectionId"); |
||||
|
||||
migrationBuilder.AddForeignKey( |
||||
"FK_PlayoutProgramScheduleItemAnchors_MediaCollections_MediaCollectionId", |
||||
"PlayoutProgramScheduleItemAnchors", |
||||
"MediaCollectionId", |
||||
"MediaCollections", |
||||
principalColumn: "Id", |
||||
onDelete: ReferentialAction.Cascade); |
||||
|
||||
migrationBuilder.AddForeignKey( |
||||
"FK_ProgramScheduleItems_MediaCollections_MediaCollectionId", |
||||
"ProgramScheduleItems", |
||||
"MediaCollectionId", |
||||
"MediaCollections", |
||||
principalColumn: "Id", |
||||
onDelete: ReferentialAction.Cascade); |
||||
} |
||||
} |
||||
} |
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue