From 0fb5bfde5854a64406edcd0e2a1c92e510160f90 Mon Sep 17 00:00:00 2001 From: Jason Dove Date: Sun, 13 Jun 2021 20:19:10 -0500 Subject: [PATCH] refactor dbcontext lifetime (#258) * refactor create playout handler * refactor get all playouts handler * refactor delete playout handler * remove dead code * ignore unnamed artists for collections * more repository cleanup * more schedule items refactoring * more playout refactoring * refactor playout builder * refactor ffmpeg profiles * more ffmpeg profile refactoring * rework resolutions * refactor media collections * refactor config elements * update changelog * more cleanup --- CHANGELOG.md | 6 + .../Artists/Queries/GetAllArtistsHandler.cs | 7 +- .../Channels/Commands/CreateChannel.cs | 2 +- .../Channels/Commands/CreateChannelHandler.cs | 65 +- .../Channels/Commands/CreateChannelResult.cs | 4 + .../Commands/SaveConfigElementByKeyHandler.cs | 15 +- .../UpdateLibraryRefreshIntervalHandler.cs | 22 +- ErsatzTV.Application/EntityIdResult.cs | 4 + .../ErsatzTV.Application.csproj | 1 + .../Commands/CreateFFmpegProfile.cs | 2 +- .../Commands/CreateFFmpegProfileHandler.cs | 62 +- .../Commands/CreateFFmpegProfileResult.cs | 4 + .../Commands/DeleteFFmpegProfile.cs | 6 +- .../Commands/DeleteFFmpegProfileHandler.cs | 43 +- .../Commands/NewFFmpegProfileHandler.cs | 23 +- .../Commands/UpdateFFmpegProfile.cs | 2 +- .../Commands/UpdateFFmpegProfileHandler.cs | 71 +- .../Commands/UpdateFFmpegProfileResult.cs | 4 + .../Commands/UpdateFFmpegSettingsHandler.cs | 32 +- .../Queries/GetAllFFmpegProfilesHandler.cs | 20 +- .../Queries/GetFFmpegProfileByIdHandler.cs | 21 +- .../Commands/UpdateHDHRTunerCountHandler.cs | 17 +- .../Queries/GetCollectionCardsHandler.cs | 60 +- .../Commands/AddArtistToCollectionHandler.cs | 64 +- .../Commands/AddEpisodeToCollectionHandler.cs | 65 +- .../Commands/AddItemsToCollectionHandler.cs | 59 +- .../Commands/AddMovieToCollectionHandler.cs | 64 +- .../AddMusicVideoToCollectionHandler.cs | 64 +- .../Commands/AddSeasonToCollectionHandler.cs | 65 +- .../Commands/AddShowToCollectionHandler.cs | 67 +- .../Commands/CreateCollectionHandler.cs | 49 +- .../Commands/DeleteCollection.cs | 5 +- .../Commands/DeleteCollectionHandler.cs | 45 +- .../RemoveItemsFromCollectionHandler.cs | 41 +- .../UpdateCollectionCustomOrderHandler.cs | 58 +- .../Commands/UpdateCollectionHandler.cs | 46 +- .../Queries/GetAllCollectionsHandler.cs | 20 +- .../Queries/GetCollectionByIdHandler.cs | 25 +- .../Queries/GetCollectionItems.cs | 9 - .../Queries/GetCollectionItemsHandler.cs | 26 - .../Queries/GetPagedCollectionsHandler.cs | 27 +- ErsatzTV.Application/MediaItems/Mapper.cs | 3 - .../MediaItemSearchResultViewModel.cs | 9 - .../MediaItems/MediaItemViewModel.cs | 4 - .../MediaItems/Queries/GetAllMediaItems.cs | 7 - .../Queries/GetAllMediaItemsHandler.cs | 24 - .../MediaItems/Queries/GetMediaItemById.cs | 7 - .../Queries/GetMediaItemByIdHandler.cs | 23 - ErsatzTV.Application/MediaSources/Mapper.cs | 16 - .../Queries/CountMediaItemsById.cs | 6 - .../Queries/CountMediaItemsByIdHandler.cs | 18 - .../Queries/GetAllMediaSources.cs | 7 - .../Queries/GetAllMediaSourcesHandler.cs | 23 - .../Queries/GetMediaSourceById.cs | 7 - .../Queries/GetMediaSourceByIdHandler.cs | 23 - .../Playouts/Commands/BuildPlayoutHandler.cs | 52 +- .../Playouts/Commands/CreatePlayout.cs | 2 +- .../Playouts/Commands/CreatePlayoutHandler.cs | 86 +- .../Commands/CreatePlayoutResponse.cs | 4 + .../Playouts/Commands/DeletePlayout.cs | 6 +- .../Playouts/Commands/DeletePlayoutHandler.cs | 44 +- .../Playouts/Commands/UpdatePlayout.cs | 13 - .../Playouts/Commands/UpdatePlayoutHandler.cs | 75 - ErsatzTV.Application/Playouts/Mapper.cs | 13 - .../Playouts/PlayoutNameViewModel.cs | 8 + .../Playouts/Queries/GetAllPlayouts.cs | 2 +- .../Playouts/Queries/GetAllPlayoutsHandler.cs | 26 +- .../Playouts/Queries/GetPlayoutById.cs | 7 - .../Playouts/Queries/GetPlayoutByIdHandler.cs | 24 - .../Queries/GetPlayoutItemsByIdHandler.cs | 45 +- .../Commands/AddProgramScheduleItemHandler.cs | 35 +- .../Commands/CreateProgramSchedule.cs | 2 +- .../Commands/CreateProgramScheduleHandler.cs | 89 +- .../Commands/CreateProgramScheduleResult.cs | 4 + .../Commands/DeleteProgramSchedule.cs | 5 +- .../Commands/DeleteProgramScheduleHandler.cs | 43 +- .../ProgramScheduleItemCommandBase.cs | 24 +- .../ReplaceProgramScheduleItemsHandler.cs | 37 +- .../Commands/UpdateProgramSchedule.cs | 2 +- .../Commands/UpdateProgramScheduleHandler.cs | 91 +- .../Commands/UpdateProgramScheduleResult.cs | 4 + .../Queries/GetAllProgramSchedulesHandler.cs | 26 +- .../Queries/GetProgramScheduleByIdHandler.cs | 24 +- .../Queries/GetProgramScheduleItems.cs | 3 +- .../Queries/GetProgramScheduleItemsHandler.cs | 45 +- .../Queries/GetAllResolutionsHandler.cs | 20 +- .../Commands/RebuildSearchIndexHandler.cs | 18 +- .../Streaming/Queries/FFmpegProcessHandler.cs | 73 +- .../GetConcatProcessByChannelNumberHandler.cs | 14 +- .../GetHlsPlaylistByChannelNumberHandler.cs | 84 +- ...layoutItemProcessByChannelNumberHandler.cs | 53 +- ErsatzTV.Application/Television/Mapper.cs | 19 - .../Queries/GetTelevisionEpisodeById.cs | 7 - .../GetTelevisionEpisodeByIdHandler.cs | 24 - .../Television/TelevisionEpisodeViewModel.cs | 10 - .../Fakes/FakeMediaCollectionRepository.cs | 18 +- ErsatzTV.Core/FFmpeg/FFmpegLocator.cs | 2 +- .../Interfaces/Metadata/ILocalFileSystem.cs | 1 - .../Repositories/IChannelRepository.cs | 2 - .../Repositories/IConfigElementRepository.cs | 3 +- .../Repositories/IFFmpegProfileRepository.cs | 9 +- .../IMediaCollectionRepository.cs | 13 +- .../Repositories/IMediaItemRepository.cs | 5 - .../Repositories/IMediaSourceRepository.cs | 7 - .../Repositories/IMovieRepository.cs | 2 - .../Repositories/IMusicVideoRepository.cs | 1 - .../Repositories/IPlayoutRepository.cs | 21 - .../IProgramScheduleRepository.cs | 18 - .../Repositories/IResolutionRepository.cs | 13 - .../Repositories/ITelevisionRepository.cs | 1 - ErsatzTV.Core/LanguageExtensions.cs | 11 +- ErsatzTV.Core/Metadata/LocalFileSystem.cs | 1 - ErsatzTV.Core/Scheduling/PlayoutBuilder.cs | 4 +- .../Data/Repositories/ChannelRepository.cs | 13 - .../Repositories/ConfigElementRepository.cs | 55 +- .../Repositories/FFmpegProfileRepository.cs | 42 +- .../Repositories/MediaCollectionRepository.cs | 239 +-- .../Data/Repositories/MediaItemRepository.cs | 33 +- .../Repositories/MediaSourceRepository.cs | 58 - .../Data/Repositories/MovieRepository.cs | 19 - .../Data/Repositories/MusicVideoRepository.cs | 17 - .../Data/Repositories/PlayoutRepository.cs | 144 -- .../Repositories/ProgramScheduleRepository.cs | 87 - .../Data/Repositories/ResolutionRepository.cs | 27 - .../Data/Repositories/TelevisionRepository.cs | 13 - ErsatzTV.Infrastructure/Data/TvContext.cs | 1 + .../ConfigElementQueryableExtensions.cs | 18 + .../PlayoutItemQueryableExtensions.cs | 23 + .../Extensions/QueryableExtensions.cs | 18 + ErsatzTV.sln | 12 - .../Controllers/Api/ChannelsController.cs | 57 - .../Api/FFmpegProfileController.cs | 57 - .../Api/MediaCollectionsController.cs | 48 - .../Controllers/Api/MediaItemsController.cs | 31 - .../Controllers/Api/MediaSourcesController.cs | 31 - ErsatzTV/Controllers/Api/PlayoutController.cs | 57 - .../Api/ProgramScheduleController.cs | 87 - ErsatzTV/ErsatzTV.csproj | 2 - ErsatzTV/Pages/Playouts.razor | 28 +- ErsatzTV/Pages/ScheduleEditor.razor | 6 +- ErsatzTV/Pages/Schedules.razor | 2 +- .../RunOnce/PlatformSettingsService.cs | 15 +- ErsatzTV/Shared/MainLayout.razor | 2 +- ErsatzTV/Startup.cs | 12 - .../.openapi-generator-ignore | 5 - .../ErsatzTV.Api.Sdk/.openapi-generator/FILES | 100 -- .../.openapi-generator/VERSION | 1 - .../src/ErsatzTV.Api.Sdk/Api/ChannelsApi.cs | 935 ---------- .../ErsatzTV.Api.Sdk/Api/FFmpegProfileApi.cs | 935 ---------- .../Api/MediaCollectionsApi.cs | 931 ---------- .../src/ErsatzTV.Api.Sdk/Api/MediaItemsApi.cs | 445 ----- .../ErsatzTV.Api.Sdk/Api/MediaSourcesApi.cs | 445 ----- .../src/ErsatzTV.Api.Sdk/Api/PlayoutApi.cs | 935 ---------- .../Api/ProgramScheduleApi.cs | 1569 ----------------- .../src/ErsatzTV.Api.Sdk/Client/ApiClient.cs | 835 --------- .../ErsatzTV.Api.Sdk/Client/ApiException.cs | 68 - .../ErsatzTV.Api.Sdk/Client/ApiResponse.cs | 166 -- .../ErsatzTV.Api.Sdk/Client/ClientUtils.cs | 214 --- .../ErsatzTV.Api.Sdk/Client/Configuration.cs | 520 ------ .../Client/ExceptionFactory.cs | 22 - .../Client/GlobalConfiguration.cs | 67 - .../src/ErsatzTV.Api.Sdk/Client/HttpMethod.cs | 33 - .../ErsatzTV.Api.Sdk/Client/IApiAccessor.cs | 37 - .../Client/IAsynchronousClient.cs | 100 -- .../Client/IReadableConfiguration.cs | 115 -- .../Client/ISynchronousClient.cs | 93 - .../src/ErsatzTV.Api.Sdk/Client/Multimap.cs | 295 ---- .../Client/OpenAPIDateConverter.cs | 29 - .../ErsatzTV.Api.Sdk/Client/RequestOptions.cs | 74 - .../Client/RetryConfiguration.cs | 21 - .../ErsatzTV.Api.Sdk/ErsatzTV.Api.Sdk.csproj | 30 - .../Model/AbstractOpenAPISchema.cs | 76 - .../Model/AddProgramScheduleItem.cs | 227 --- .../Model/ChannelViewModel.cs | 196 -- .../ErsatzTV.Api.Sdk/Model/CreateChannel.cs | 182 -- .../Model/CreateFFmpegProfile.cs | 353 ---- .../ErsatzTV.Api.Sdk/Model/CreatePlayout.cs | 150 -- .../Model/CreateProgramSchedule.cs | 138 -- .../Model/CreateSimpleMediaCollection.cs | 125 -- .../ErsatzTV.Api.Sdk/Model/DeleteChannel.cs | 123 -- .../Model/DeleteFFmpegProfile.cs | 123 -- .../ErsatzTV.Api.Sdk/Model/DeletePlayout.cs | 123 -- .../Model/DeleteProgramSchedule.cs | 123 -- .../Model/FFmpegProfileViewModel.cs | 369 ---- .../Model/MediaCollectionViewModel.cs | 139 -- .../Model/MediaItemViewModel.cs | 153 -- .../ErsatzTV.Api.Sdk/Model/MediaSourceType.cs | 62 - .../Model/MediaSourceViewModel.cs | 152 -- .../ErsatzTV.Api.Sdk/Model/PlaybackOrder.cs | 56 - .../Model/PlayoutChannelViewModel.cs | 153 -- .../src/ErsatzTV.Api.Sdk/Model/PlayoutMode.cs | 62 - .../Model/PlayoutProgramScheduleViewModel.cs | 139 -- .../Model/PlayoutViewModel.cs | 168 -- .../ErsatzTV.Api.Sdk/Model/ProblemDetails.cs | 190 -- .../Model/ProgramScheduleItemViewModel.cs | 195 -- .../Model/ProgramSchedulePlayoutType.cs | 56 - .../Model/ProgramScheduleViewModel.cs | 152 -- .../Model/ReplaceProgramScheduleItem.cs | 227 --- .../Model/ResolutionViewModel.cs | 167 -- .../src/ErsatzTV.Api.Sdk/Model/StartType.cs | 50 - .../ErsatzTV.Api.Sdk/Model/StreamingMode.cs | 50 - .../ErsatzTV.Api.Sdk/Model/UpdateChannel.cs | 196 -- .../Model/UpdateFFmpegProfile.cs | 367 ---- .../ErsatzTV.Api.Sdk/Model/UpdatePlayout.cs | 164 -- .../Model/UpdateProgramSchedule.cs | 152 -- .../.openapi-generator-ignore | 5 - scripts/generate-api-sdk/generate-api-sdk.sh | 24 - scripts/generate-api-sdk/openapitools.json | 7 - 208 files changed, 1515 insertions(+), 16917 deletions(-) create mode 100644 ErsatzTV.Application/Channels/Commands/CreateChannelResult.cs create mode 100644 ErsatzTV.Application/EntityIdResult.cs create mode 100644 ErsatzTV.Application/FFmpegProfiles/Commands/CreateFFmpegProfileResult.cs create mode 100644 ErsatzTV.Application/FFmpegProfiles/Commands/UpdateFFmpegProfileResult.cs delete mode 100644 ErsatzTV.Application/MediaCollections/Queries/GetCollectionItems.cs delete mode 100644 ErsatzTV.Application/MediaCollections/Queries/GetCollectionItemsHandler.cs delete mode 100644 ErsatzTV.Application/MediaItems/MediaItemSearchResultViewModel.cs delete mode 100644 ErsatzTV.Application/MediaItems/MediaItemViewModel.cs delete mode 100644 ErsatzTV.Application/MediaItems/Queries/GetAllMediaItems.cs delete mode 100644 ErsatzTV.Application/MediaItems/Queries/GetAllMediaItemsHandler.cs delete mode 100644 ErsatzTV.Application/MediaItems/Queries/GetMediaItemById.cs delete mode 100644 ErsatzTV.Application/MediaItems/Queries/GetMediaItemByIdHandler.cs delete mode 100644 ErsatzTV.Application/MediaSources/Mapper.cs delete mode 100644 ErsatzTV.Application/MediaSources/Queries/CountMediaItemsById.cs delete mode 100644 ErsatzTV.Application/MediaSources/Queries/CountMediaItemsByIdHandler.cs delete mode 100644 ErsatzTV.Application/MediaSources/Queries/GetAllMediaSources.cs delete mode 100644 ErsatzTV.Application/MediaSources/Queries/GetAllMediaSourcesHandler.cs delete mode 100644 ErsatzTV.Application/MediaSources/Queries/GetMediaSourceById.cs delete mode 100644 ErsatzTV.Application/MediaSources/Queries/GetMediaSourceByIdHandler.cs create mode 100644 ErsatzTV.Application/Playouts/Commands/CreatePlayoutResponse.cs delete mode 100644 ErsatzTV.Application/Playouts/Commands/UpdatePlayout.cs delete mode 100644 ErsatzTV.Application/Playouts/Commands/UpdatePlayoutHandler.cs create mode 100644 ErsatzTV.Application/Playouts/PlayoutNameViewModel.cs delete mode 100644 ErsatzTV.Application/Playouts/Queries/GetPlayoutById.cs delete mode 100644 ErsatzTV.Application/Playouts/Queries/GetPlayoutByIdHandler.cs create mode 100644 ErsatzTV.Application/ProgramSchedules/Commands/CreateProgramScheduleResult.cs create mode 100644 ErsatzTV.Application/ProgramSchedules/Commands/UpdateProgramScheduleResult.cs delete mode 100644 ErsatzTV.Application/Television/Queries/GetTelevisionEpisodeById.cs delete mode 100644 ErsatzTV.Application/Television/Queries/GetTelevisionEpisodeByIdHandler.cs delete mode 100644 ErsatzTV.Application/Television/TelevisionEpisodeViewModel.cs delete mode 100644 ErsatzTV.Core/Interfaces/Repositories/IPlayoutRepository.cs delete mode 100644 ErsatzTV.Core/Interfaces/Repositories/IProgramScheduleRepository.cs delete mode 100644 ErsatzTV.Core/Interfaces/Repositories/IResolutionRepository.cs delete mode 100644 ErsatzTV.Infrastructure/Data/Repositories/PlayoutRepository.cs delete mode 100644 ErsatzTV.Infrastructure/Data/Repositories/ProgramScheduleRepository.cs delete mode 100644 ErsatzTV.Infrastructure/Data/Repositories/ResolutionRepository.cs create mode 100644 ErsatzTV.Infrastructure/Extensions/ConfigElementQueryableExtensions.cs create mode 100644 ErsatzTV.Infrastructure/Extensions/PlayoutItemQueryableExtensions.cs create mode 100644 ErsatzTV.Infrastructure/Extensions/QueryableExtensions.cs delete mode 100644 ErsatzTV/Controllers/Api/ChannelsController.cs delete mode 100644 ErsatzTV/Controllers/Api/FFmpegProfileController.cs delete mode 100644 ErsatzTV/Controllers/Api/MediaCollectionsController.cs delete mode 100644 ErsatzTV/Controllers/Api/MediaItemsController.cs delete mode 100644 ErsatzTV/Controllers/Api/MediaSourcesController.cs delete mode 100644 ErsatzTV/Controllers/Api/PlayoutController.cs delete mode 100644 ErsatzTV/Controllers/Api/ProgramScheduleController.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/.openapi-generator-ignore delete mode 100644 generated/ErsatzTV.Api.Sdk/.openapi-generator/FILES delete mode 100644 generated/ErsatzTV.Api.Sdk/.openapi-generator/VERSION delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/ChannelsApi.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/FFmpegProfileApi.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/MediaCollectionsApi.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/MediaItemsApi.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/MediaSourcesApi.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/PlayoutApi.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/ProgramScheduleApi.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/ApiClient.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/ApiException.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/ApiResponse.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/ClientUtils.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/Configuration.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/ExceptionFactory.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/GlobalConfiguration.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/HttpMethod.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/IApiAccessor.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/IAsynchronousClient.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/IReadableConfiguration.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/ISynchronousClient.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/Multimap.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/OpenAPIDateConverter.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/RequestOptions.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/RetryConfiguration.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/ErsatzTV.Api.Sdk.csproj delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/AbstractOpenAPISchema.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/AddProgramScheduleItem.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ChannelViewModel.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/CreateChannel.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/CreateFFmpegProfile.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/CreatePlayout.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/CreateProgramSchedule.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/CreateSimpleMediaCollection.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/DeleteChannel.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/DeleteFFmpegProfile.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/DeletePlayout.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/DeleteProgramSchedule.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/FFmpegProfileViewModel.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/MediaCollectionViewModel.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/MediaItemViewModel.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/MediaSourceType.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/MediaSourceViewModel.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/PlaybackOrder.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/PlayoutChannelViewModel.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/PlayoutMode.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/PlayoutProgramScheduleViewModel.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/PlayoutViewModel.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ProblemDetails.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ProgramScheduleItemViewModel.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ProgramSchedulePlayoutType.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ProgramScheduleViewModel.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ReplaceProgramScheduleItem.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ResolutionViewModel.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/StartType.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/StreamingMode.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/UpdateChannel.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/UpdateFFmpegProfile.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/UpdatePlayout.cs delete mode 100644 generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/UpdateProgramSchedule.cs delete mode 100644 scripts/generate-api-sdk/.openapi-generator-ignore delete mode 100755 scripts/generate-api-sdk/generate-api-sdk.sh delete mode 100644 scripts/generate-api-sdk/openapitools.json diff --git a/CHANGELOG.md b/CHANGELOG.md index edab1424b..fe1322bc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +### Changed +- Remove unused API and SDK project; may reintroduce in the future but for now they have fallen out of date + +### Fixed +- Fix crash adding or editing schedule items due to Artist with no name +- Fix many potential sources of inconsistent data in UI ## [0.0.45-prealpha] - 2021-06-12 ### Added diff --git a/ErsatzTV.Application/Artists/Queries/GetAllArtistsHandler.cs b/ErsatzTV.Application/Artists/Queries/GetAllArtistsHandler.cs index 344f8a05c..d059c08d3 100644 --- a/ErsatzTV.Application/Artists/Queries/GetAllArtistsHandler.cs +++ b/ErsatzTV.Application/Artists/Queries/GetAllArtistsHandler.cs @@ -19,6 +19,11 @@ namespace ErsatzTV.Application.Artists.Queries public Task> Handle( GetAllArtists request, CancellationToken cancellationToken) => - _artistRepository.GetAllArtists().Map(list => list.Map(ProjectToViewModel).ToList()); + _artistRepository.GetAllArtists() + .Map( + list => list.Filter( + a => !string.IsNullOrWhiteSpace( + a.ArtistMetadata.HeadOrNone().Match(am => am.Title, () => string.Empty)))) + .Map(list => list.Map(ProjectToViewModel).ToList()); } } diff --git a/ErsatzTV.Application/Channels/Commands/CreateChannel.cs b/ErsatzTV.Application/Channels/Commands/CreateChannel.cs index 3e6d20373..377f6252a 100644 --- a/ErsatzTV.Application/Channels/Commands/CreateChannel.cs +++ b/ErsatzTV.Application/Channels/Commands/CreateChannel.cs @@ -20,5 +20,5 @@ namespace ErsatzTV.Application.Channels.Commands int WatermarkHorizontalMargin, int WatermarkVerticalMargin, int WatermarkFrequencyMinutes, - int WatermarkDurationSeconds) : IRequest>; + int WatermarkDurationSeconds) : IRequest>; } diff --git a/ErsatzTV.Application/Channels/Commands/CreateChannelHandler.cs b/ErsatzTV.Application/Channels/Commands/CreateChannelHandler.cs index 14254684b..43d62723e 100644 --- a/ErsatzTV.Application/Channels/Commands/CreateChannelHandler.cs +++ b/ErsatzTV.Application/Channels/Commands/CreateChannelHandler.cs @@ -7,39 +7,40 @@ using System.Threading; using System.Threading.Tasks; using ErsatzTV.Core; using ErsatzTV.Core.Domain; -using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; using MediatR; -using static ErsatzTV.Application.Channels.Mapper; +using Microsoft.EntityFrameworkCore; using static LanguageExt.Prelude; namespace ErsatzTV.Application.Channels.Commands { - public class CreateChannelHandler : IRequestHandler> + public class CreateChannelHandler : IRequestHandler> { - private readonly IChannelRepository _channelRepository; - private readonly IFFmpegProfileRepository _ffmpegProfileRepository; + private readonly IDbContextFactory _dbContextFactory; - public CreateChannelHandler( - IChannelRepository channelRepository, - IFFmpegProfileRepository ffmpegProfileRepository) - { - _channelRepository = channelRepository; - _ffmpegProfileRepository = ffmpegProfileRepository; - } + public CreateChannelHandler(IDbContextFactory dbContextFactory) => _dbContextFactory = dbContextFactory; - public Task> Handle( + public async Task> Handle( CreateChannel request, - CancellationToken cancellationToken) => - Validate(request) - .MapT(PersistChannel) - .Bind(v => v.ToEitherAsync()); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + Validation validation = await Validate(dbContext, request); + return await validation.Apply(c => PersistChannel(dbContext, c)); + } - private Task PersistChannel(Channel c) => - _channelRepository.Add(c).Map(ProjectToViewModel); + private static async Task PersistChannel(TvContext dbContext, Channel channel) + { + await dbContext.Channels.AddAsync(channel); + await dbContext.SaveChangesAsync(); + return new CreateChannelResult(channel.Id); + } - private async Task> Validate(CreateChannel request) => - (ValidateName(request), await ValidateNumber(request), await FFmpegProfileMustExist(request), + private async Task> Validate(TvContext dbContext, CreateChannel request) => + (ValidateName(request), await ValidateNumber(dbContext, request), + await FFmpegProfileMustExist(dbContext, request), ValidatePreferredLanguage(request)) .Apply( (name, number, ffmpegProfileId, preferredLanguageCode) => @@ -85,20 +86,21 @@ namespace ErsatzTV.Application.Channels.Commands return channel; }); - private Validation ValidateName(CreateChannel createChannel) => + private static Validation ValidateName(CreateChannel createChannel) => createChannel.NotEmpty(c => c.Name) .Bind(_ => createChannel.NotLongerThan(50)(c => c.Name)); - private Validation ValidatePreferredLanguage(CreateChannel createChannel) => + private static Validation ValidatePreferredLanguage(CreateChannel createChannel) => Optional(createChannel.PreferredLanguageCode ?? string.Empty) .Filter( lc => string.IsNullOrWhiteSpace(lc) || CultureInfo.GetCultures(CultureTypes.NeutralCultures).Any( ci => string.Equals(ci.ThreeLetterISOLanguageName, lc, StringComparison.OrdinalIgnoreCase))) .ToValidation("Preferred language code is invalid"); - private async Task> ValidateNumber(CreateChannel createChannel) + private static async Task> ValidateNumber(TvContext dbContext, CreateChannel createChannel) { - Option maybeExistingChannel = await _channelRepository.GetByNumber(createChannel.Number); + Option maybeExistingChannel = await dbContext.Channels + .SelectOneAsync(c => c.Number, c => c.Number == createChannel.Number); return maybeExistingChannel.Match>( _ => BaseError.New("Channel number must be unique"), () => @@ -112,9 +114,14 @@ namespace ErsatzTV.Application.Channels.Commands }); } - private async Task> FFmpegProfileMustExist(CreateChannel createChannel) => - (await _ffmpegProfileRepository.Get(createChannel.FFmpegProfileId)) - .ToValidation($"FFmpegProfile {createChannel.FFmpegProfileId} does not exist.") - .Map(c => c.Id); + private static Task> FFmpegProfileMustExist( + TvContext dbContext, + CreateChannel createChannel) => + dbContext.FFmpegProfiles + .CountAsync(p => p.Id == createChannel.FFmpegProfileId) + .Map(Optional) + .Filter(c => c > 0) + .MapT(_ => createChannel.FFmpegProfileId) + .Map(o => o.ToValidation($"FFmpegProfile {createChannel.FFmpegProfileId} does not exist.")); } } diff --git a/ErsatzTV.Application/Channels/Commands/CreateChannelResult.cs b/ErsatzTV.Application/Channels/Commands/CreateChannelResult.cs new file mode 100644 index 000000000..ccd147197 --- /dev/null +++ b/ErsatzTV.Application/Channels/Commands/CreateChannelResult.cs @@ -0,0 +1,4 @@ +namespace ErsatzTV.Application.Channels.Commands +{ + public record CreateChannelResult(int ChannelId) : EntityIdResult(ChannelId); +} diff --git a/ErsatzTV.Application/Configuration/Commands/SaveConfigElementByKeyHandler.cs b/ErsatzTV.Application/Configuration/Commands/SaveConfigElementByKeyHandler.cs index 504dd5cec..d2bdb4a72 100644 --- a/ErsatzTV.Application/Configuration/Commands/SaveConfigElementByKeyHandler.cs +++ b/ErsatzTV.Application/Configuration/Commands/SaveConfigElementByKeyHandler.cs @@ -1,6 +1,5 @@ using System.Threading; using System.Threading.Tasks; -using ErsatzTV.Core.Domain; using ErsatzTV.Core.Interfaces.Repositories; using LanguageExt; @@ -15,19 +14,7 @@ namespace ErsatzTV.Application.Configuration.Commands public async Task Handle(SaveConfigElementByKey request, CancellationToken cancellationToken) { - Option maybeElement = await _configElementRepository.Get(request.Key); - await maybeElement.Match( - ce => - { - ce.Value = request.Value; - return _configElementRepository.Update(ce); - }, - () => - { - var ce = new ConfigElement { Key = request.Key.Key, Value = request.Value }; - return _configElementRepository.Add(ce); - }); - + await _configElementRepository.Upsert(request.Key, request.Value); return Unit.Default; } } diff --git a/ErsatzTV.Application/Configuration/Commands/UpdateLibraryRefreshIntervalHandler.cs b/ErsatzTV.Application/Configuration/Commands/UpdateLibraryRefreshIntervalHandler.cs index d0fe4cf71..43043bb50 100644 --- a/ErsatzTV.Application/Configuration/Commands/UpdateLibraryRefreshIntervalHandler.cs +++ b/ErsatzTV.Application/Configuration/Commands/UpdateLibraryRefreshIntervalHandler.cs @@ -8,9 +8,8 @@ using static LanguageExt.Prelude; namespace ErsatzTV.Application.Configuration.Commands { - public class - UpdateLibraryRefreshIntervalHandler : MediatR.IRequestHandler> + public class UpdateLibraryRefreshIntervalHandler : + MediatR.IRequestHandler> { private readonly IConfigElementRepository _configElementRepository; @@ -21,27 +20,14 @@ namespace ErsatzTV.Application.Configuration.Commands UpdateLibraryRefreshInterval request, CancellationToken cancellationToken) => Validate(request) - .MapT(_ => Upsert(ConfigElementKey.LibraryRefreshInterval, request.LibraryRefreshInterval.ToString())) + .MapT(_ => _configElementRepository.Upsert(ConfigElementKey.LibraryRefreshInterval, request.LibraryRefreshInterval)) .Bind(v => v.ToEitherAsync()); - private Task> Validate(UpdateLibraryRefreshInterval request) => + private static Task> Validate(UpdateLibraryRefreshInterval request) => Optional(request.LibraryRefreshInterval) .Filter(lri => lri > 0) .Map(_ => Unit.Default) .ToValidation("Tuner count must be greater than zero") .AsTask(); - - private Task Upsert(ConfigElementKey key, string value) => - _configElementRepository.Get(key).Match( - ce => - { - ce.Value = value; - return _configElementRepository.Update(ce); - }, - () => - { - var ce = new ConfigElement { Key = key.Key, Value = value }; - return _configElementRepository.Add(ce); - }).ToUnit(); } } diff --git a/ErsatzTV.Application/EntityIdResult.cs b/ErsatzTV.Application/EntityIdResult.cs new file mode 100644 index 000000000..a39fdc7e3 --- /dev/null +++ b/ErsatzTV.Application/EntityIdResult.cs @@ -0,0 +1,4 @@ +namespace ErsatzTV.Application +{ + public record EntityIdResult(int Id); +} diff --git a/ErsatzTV.Application/ErsatzTV.Application.csproj b/ErsatzTV.Application/ErsatzTV.Application.csproj index df324b447..2570d980b 100644 --- a/ErsatzTV.Application/ErsatzTV.Application.csproj +++ b/ErsatzTV.Application/ErsatzTV.Application.csproj @@ -23,6 +23,7 @@ + diff --git a/ErsatzTV.Application/FFmpegProfiles/Commands/CreateFFmpegProfile.cs b/ErsatzTV.Application/FFmpegProfiles/Commands/CreateFFmpegProfile.cs index 682f40c5e..7d05ec499 100644 --- a/ErsatzTV.Application/FFmpegProfiles/Commands/CreateFFmpegProfile.cs +++ b/ErsatzTV.Application/FFmpegProfiles/Commands/CreateFFmpegProfile.cs @@ -21,5 +21,5 @@ namespace ErsatzTV.Application.FFmpegProfiles.Commands bool NormalizeLoudness, int AudioChannels, int AudioSampleRate, - bool NormalizeAudio) : IRequest>; + bool NormalizeAudio) : IRequest>; } diff --git a/ErsatzTV.Application/FFmpegProfiles/Commands/CreateFFmpegProfileHandler.cs b/ErsatzTV.Application/FFmpegProfiles/Commands/CreateFFmpegProfileHandler.cs index 5e477d436..5096b4076 100644 --- a/ErsatzTV.Application/FFmpegProfiles/Commands/CreateFFmpegProfileHandler.cs +++ b/ErsatzTV.Application/FFmpegProfiles/Commands/CreateFFmpegProfileHandler.cs @@ -2,39 +2,42 @@ using System.Threading.Tasks; using ErsatzTV.Core; using ErsatzTV.Core.Domain; -using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; using MediatR; -using static ErsatzTV.Application.FFmpegProfiles.Mapper; +using Microsoft.EntityFrameworkCore; namespace ErsatzTV.Application.FFmpegProfiles.Commands { - public class - CreateFFmpegProfileHandler : IRequestHandler> + public class CreateFFmpegProfileHandler : + IRequestHandler> { - private readonly IFFmpegProfileRepository _ffmpegProfileRepository; - private readonly IResolutionRepository _resolutionRepository; + private readonly IDbContextFactory _dbContextFactory; - public CreateFFmpegProfileHandler( - IFFmpegProfileRepository ffmpegProfileRepository, - IResolutionRepository resolutionRepository) - { - _ffmpegProfileRepository = ffmpegProfileRepository; - _resolutionRepository = resolutionRepository; - } + public CreateFFmpegProfileHandler(IDbContextFactory dbContextFactory) => + _dbContextFactory = dbContextFactory; - public Task> Handle( + public async Task> Handle( CreateFFmpegProfile request, - CancellationToken cancellationToken) => - Validate(request) - .MapT(PersistFFmpegProfile) - .Bind(v => v.ToEitherAsync()); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + Validation validation = await Validate(dbContext, request); + return await validation.Apply(profile => PersistFFmpegProfile(dbContext, profile)); + } - private Task PersistFFmpegProfile(FFmpegProfile ffmpegProfile) => - _ffmpegProfileRepository.Add(ffmpegProfile).Map(ProjectToViewModel); + private static async Task PersistFFmpegProfile( + TvContext dbContext, + FFmpegProfile ffmpegProfile) + { + await dbContext.FFmpegProfiles.AddAsync(ffmpegProfile); + await dbContext.SaveChangesAsync(); + return new CreateFFmpegProfileResult(ffmpegProfile.Id); + } - private async Task> Validate(CreateFFmpegProfile request) => - (ValidateName(request), ValidateThreadCount(request), await ResolutionMustExist(request)) + private async Task> Validate(TvContext dbContext, CreateFFmpegProfile request) => + (ValidateName(request), ValidateThreadCount(request), await ResolutionMustExist(dbContext, request)) .Apply( (name, threadCount, resolutionId) => new FFmpegProfile { @@ -56,16 +59,19 @@ namespace ErsatzTV.Application.FFmpegProfiles.Commands NormalizeAudio = request.NormalizeAudio }); - private Validation ValidateName(CreateFFmpegProfile createFFmpegProfile) => + private static Validation ValidateName(CreateFFmpegProfile createFFmpegProfile) => createFFmpegProfile.NotEmpty(x => x.Name) .Bind(_ => createFFmpegProfile.NotLongerThan(50)(x => x.Name)); - private Validation ValidateThreadCount(CreateFFmpegProfile createFFmpegProfile) => + private static Validation ValidateThreadCount(CreateFFmpegProfile createFFmpegProfile) => createFFmpegProfile.AtLeast(0)(p => p.ThreadCount); - private async Task> ResolutionMustExist(CreateFFmpegProfile createFFmpegProfile) => - (await _resolutionRepository.Get(createFFmpegProfile.ResolutionId)) - .ToValidation($"[Resolution] {createFFmpegProfile.ResolutionId} does not exist.") - .Map(c => c.Id); + private static Task> ResolutionMustExist( + TvContext dbContext, + CreateFFmpegProfile createFFmpegProfile) => + dbContext.Resolutions + .SelectOneAsync(r => r.Id, r => r.Id == createFFmpegProfile.ResolutionId) + .MapT(r => r.Id) + .Map(o => o.ToValidation($"[Resolution] {createFFmpegProfile.ResolutionId} does not exist")); } } diff --git a/ErsatzTV.Application/FFmpegProfiles/Commands/CreateFFmpegProfileResult.cs b/ErsatzTV.Application/FFmpegProfiles/Commands/CreateFFmpegProfileResult.cs new file mode 100644 index 000000000..25c68e0a3 --- /dev/null +++ b/ErsatzTV.Application/FFmpegProfiles/Commands/CreateFFmpegProfileResult.cs @@ -0,0 +1,4 @@ +namespace ErsatzTV.Application.FFmpegProfiles.Commands +{ + public record CreateFFmpegProfileResult(int FFmpegProfileId) : EntityIdResult(FFmpegProfileId); +} diff --git a/ErsatzTV.Application/FFmpegProfiles/Commands/DeleteFFmpegProfile.cs b/ErsatzTV.Application/FFmpegProfiles/Commands/DeleteFFmpegProfile.cs index b7d8f9d63..fc4c52448 100644 --- a/ErsatzTV.Application/FFmpegProfiles/Commands/DeleteFFmpegProfile.cs +++ b/ErsatzTV.Application/FFmpegProfiles/Commands/DeleteFFmpegProfile.cs @@ -1,9 +1,7 @@ -using System.Threading.Tasks; -using ErsatzTV.Core; +using ErsatzTV.Core; using LanguageExt; -using MediatR; namespace ErsatzTV.Application.FFmpegProfiles.Commands { - public record DeleteFFmpegProfile(int FFmpegProfileId) : IRequest>; + public record DeleteFFmpegProfile(int FFmpegProfileId) : MediatR.IRequest>; } diff --git a/ErsatzTV.Application/FFmpegProfiles/Commands/DeleteFFmpegProfileHandler.cs b/ErsatzTV.Application/FFmpegProfiles/Commands/DeleteFFmpegProfileHandler.cs index d0bb36381..ae01345d0 100644 --- a/ErsatzTV.Application/FFmpegProfiles/Commands/DeleteFFmpegProfileHandler.cs +++ b/ErsatzTV.Application/FFmpegProfiles/Commands/DeleteFFmpegProfileHandler.cs @@ -1,32 +1,43 @@ using System.Threading; using System.Threading.Tasks; using ErsatzTV.Core; -using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Core.Domain; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; using MediatR; +using Microsoft.EntityFrameworkCore; namespace ErsatzTV.Application.FFmpegProfiles.Commands { - public class DeleteFFmpegProfileHandler : IRequestHandler> + public class DeleteFFmpegProfileHandler : IRequestHandler> { - private readonly IFFmpegProfileRepository _ffmpegProfileRepository; + private readonly IDbContextFactory _dbContextFactory; - public DeleteFFmpegProfileHandler(IFFmpegProfileRepository ffmpegProfileRepository) => - _ffmpegProfileRepository = ffmpegProfileRepository; + public DeleteFFmpegProfileHandler(IDbContextFactory dbContextFactory) => + _dbContextFactory = dbContextFactory; - public async Task> Handle( + public async Task> Handle( DeleteFFmpegProfile request, - CancellationToken cancellationToken) => - (await FFmpegProfileMustExist(request)) - .Map(DoDeletion) - .ToEither(); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + Validation validation = await FFmpegProfileMustExist(dbContext, request); + return await validation.Apply(p => DoDeletion(dbContext, p)); + } - private Task DoDeletion(int channelId) => _ffmpegProfileRepository.Delete(channelId); + private static async Task DoDeletion(TvContext dbContext, FFmpegProfile ffmpegProfile) + { + dbContext.FFmpegProfiles.Remove(ffmpegProfile); + await dbContext.SaveChangesAsync(); + return LanguageExt.Unit.Default; + } - private async Task> FFmpegProfileMustExist( - DeleteFFmpegProfile deleteFFmpegProfile) => - (await _ffmpegProfileRepository.Get(deleteFFmpegProfile.FFmpegProfileId)) - .ToValidation($"FFmpegProfile {deleteFFmpegProfile.FFmpegProfileId} does not exist.") - .Map(c => c.Id); + private static Task> FFmpegProfileMustExist( + TvContext dbContext, + DeleteFFmpegProfile request) => + dbContext.FFmpegProfiles + .SelectOneAsync(p => p.Id, p => p.Id == request.FFmpegProfileId) + .Map(o => o.ToValidation($"FFmpegProfile {request.FFmpegProfileId} does not exist")); } } diff --git a/ErsatzTV.Application/FFmpegProfiles/Commands/NewFFmpegProfileHandler.cs b/ErsatzTV.Application/FFmpegProfiles/Commands/NewFFmpegProfileHandler.cs index 4c078d52f..1150feb29 100644 --- a/ErsatzTV.Application/FFmpegProfiles/Commands/NewFFmpegProfileHandler.cs +++ b/ErsatzTV.Application/FFmpegProfiles/Commands/NewFFmpegProfileHandler.cs @@ -2,9 +2,11 @@ using System.Threading; using System.Threading.Tasks; using ErsatzTV.Core.Domain; -using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; using MediatR; +using Microsoft.EntityFrameworkCore; using static LanguageExt.Prelude; using static ErsatzTV.Application.FFmpegProfiles.Mapper; @@ -12,24 +14,21 @@ namespace ErsatzTV.Application.FFmpegProfiles.Commands { public class NewFFmpegProfileHandler : IRequestHandler { - private readonly IConfigElementRepository _configElementRepository; - private readonly IResolutionRepository _resolutionRepository; + private readonly IDbContextFactory _dbContextFactory; - public NewFFmpegProfileHandler( - IResolutionRepository resolutionRepository, - IConfigElementRepository configElementRepository) - { - _resolutionRepository = resolutionRepository; - _configElementRepository = configElementRepository; - } + public NewFFmpegProfileHandler(IDbContextFactory dbContextFactory) => + _dbContextFactory = dbContextFactory; public async Task Handle(NewFFmpegProfile request, CancellationToken cancellationToken) { - int defaultResolutionId = await _configElementRepository + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + + int defaultResolutionId = await dbContext.ConfigElements .GetValue(ConfigElementKey.FFmpegDefaultResolutionId) .IfNoneAsync(0); - List allResolutions = await _resolutionRepository.GetAll(); + List allResolutions = await dbContext.Resolutions + .ToListAsync(cancellationToken); Option maybeDefaultResolution = allResolutions.Find(r => r.Id == defaultResolutionId); Resolution defaultResolution = maybeDefaultResolution.Match(identity, () => allResolutions.Head()); diff --git a/ErsatzTV.Application/FFmpegProfiles/Commands/UpdateFFmpegProfile.cs b/ErsatzTV.Application/FFmpegProfiles/Commands/UpdateFFmpegProfile.cs index df3febcc8..8463b2670 100644 --- a/ErsatzTV.Application/FFmpegProfiles/Commands/UpdateFFmpegProfile.cs +++ b/ErsatzTV.Application/FFmpegProfiles/Commands/UpdateFFmpegProfile.cs @@ -22,5 +22,5 @@ namespace ErsatzTV.Application.FFmpegProfiles.Commands bool NormalizeLoudness, int AudioChannels, int AudioSampleRate, - bool NormalizeAudio) : IRequest>; + bool NormalizeAudio) : IRequest>; } diff --git a/ErsatzTV.Application/FFmpegProfiles/Commands/UpdateFFmpegProfileHandler.cs b/ErsatzTV.Application/FFmpegProfiles/Commands/UpdateFFmpegProfileHandler.cs index 02918e90b..50a1870ad 100644 --- a/ErsatzTV.Application/FFmpegProfiles/Commands/UpdateFFmpegProfileHandler.cs +++ b/ErsatzTV.Application/FFmpegProfiles/Commands/UpdateFFmpegProfileHandler.cs @@ -2,35 +2,35 @@ using System.Threading.Tasks; using ErsatzTV.Core; using ErsatzTV.Core.Domain; -using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; using MediatR; -using static ErsatzTV.Application.FFmpegProfiles.Mapper; +using Microsoft.EntityFrameworkCore; namespace ErsatzTV.Application.FFmpegProfiles.Commands { public class - UpdateFFmpegProfileHandler : IRequestHandler> + UpdateFFmpegProfileHandler : IRequestHandler> { - private readonly IFFmpegProfileRepository _ffmpegProfileRepository; - private readonly IResolutionRepository _resolutionRepository; + private readonly IDbContextFactory _dbContextFactory; - public UpdateFFmpegProfileHandler( - IFFmpegProfileRepository ffmpegProfileRepository, - IResolutionRepository resolutionRepository) - { - _ffmpegProfileRepository = ffmpegProfileRepository; - _resolutionRepository = resolutionRepository; - } + public UpdateFFmpegProfileHandler(IDbContextFactory dbContextFactory) => + _dbContextFactory = dbContextFactory; - public Task> Handle( + public async Task> Handle( UpdateFFmpegProfile request, - CancellationToken cancellationToken) => - Validate(request) - .MapT(c => ApplyUpdateRequest(c, request)) - .Bind(v => v.ToEitherAsync()); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + Validation validation = await Validate(dbContext, request); + return await validation.Apply(p => ApplyUpdateRequest(dbContext, p, request)); + } - private async Task ApplyUpdateRequest(FFmpegProfile p, UpdateFFmpegProfile update) + private async Task ApplyUpdateRequest( + TvContext dbContext, + FFmpegProfile p, + UpdateFFmpegProfile update) { p.Name = update.Name; p.ThreadCount = update.ThreadCount; @@ -48,30 +48,37 @@ namespace ErsatzTV.Application.FFmpegProfiles.Commands p.AudioChannels = update.AudioChannels; p.AudioSampleRate = update.AudioSampleRate; p.NormalizeAudio = update.NormalizeAudio; - await _ffmpegProfileRepository.Update(p); - return ProjectToViewModel(p); + await dbContext.SaveChangesAsync(); + return new UpdateFFmpegProfileResult(p.Id); } - private async Task> Validate(UpdateFFmpegProfile request) => - (await FFmpegProfileMustExist(request), ValidateName(request), ValidateThreadCount(request), - await ResolutionMustExist(request)) + private static async Task> Validate( + TvContext dbContext, + UpdateFFmpegProfile request) => + (await FFmpegProfileMustExist(dbContext, request), ValidateName(request), ValidateThreadCount(request), + await ResolutionMustExist(dbContext, request)) .Apply((ffmpegProfileToUpdate, _, _, _) => ffmpegProfileToUpdate); - private async Task> FFmpegProfileMustExist( + private static Task> FFmpegProfileMustExist( + TvContext dbContext, UpdateFFmpegProfile updateFFmpegProfile) => - (await _ffmpegProfileRepository.Get(updateFFmpegProfile.FFmpegProfileId)) - .ToValidation("FFmpegProfile does not exist."); + dbContext.FFmpegProfiles + .SelectOneAsync(p => p.Id, p => p.Id == updateFFmpegProfile.FFmpegProfileId) + .Map(o => o.ToValidation("FFmpegProfile does not exist.")); - private Validation ValidateName(UpdateFFmpegProfile updateFFmpegProfile) => + private static Validation ValidateName(UpdateFFmpegProfile updateFFmpegProfile) => updateFFmpegProfile.NotEmpty(x => x.Name) .Bind(_ => updateFFmpegProfile.NotLongerThan(50)(x => x.Name)); - private Validation ValidateThreadCount(UpdateFFmpegProfile updateFFmpegProfile) => + private static Validation ValidateThreadCount(UpdateFFmpegProfile updateFFmpegProfile) => updateFFmpegProfile.AtLeast(0)(p => p.ThreadCount); - private async Task> ResolutionMustExist(UpdateFFmpegProfile updateFFmpegProfile) => - (await _resolutionRepository.Get(updateFFmpegProfile.ResolutionId)) - .ToValidation($"[Resolution] {updateFFmpegProfile.ResolutionId} does not exist.") - .Map(c => c.Id); + private static Task> ResolutionMustExist( + TvContext dbContext, + UpdateFFmpegProfile updateFFmpegProfile) => + dbContext.Resolutions + .SelectOneAsync(r => r.Id, r => r.Id == updateFFmpegProfile.ResolutionId) + .MapT(r => r.Id) + .Map(o => o.ToValidation($"[Resolution] {updateFFmpegProfile.ResolutionId} does not exist")); } } diff --git a/ErsatzTV.Application/FFmpegProfiles/Commands/UpdateFFmpegProfileResult.cs b/ErsatzTV.Application/FFmpegProfiles/Commands/UpdateFFmpegProfileResult.cs new file mode 100644 index 000000000..c574c6ed0 --- /dev/null +++ b/ErsatzTV.Application/FFmpegProfiles/Commands/UpdateFFmpegProfileResult.cs @@ -0,0 +1,4 @@ +namespace ErsatzTV.Application.FFmpegProfiles.Commands +{ + public record UpdateFFmpegProfileResult(int FFmpegProfileId) : EntityIdResult(FFmpegProfileId); +} diff --git a/ErsatzTV.Application/FFmpegProfiles/Commands/UpdateFFmpegSettingsHandler.cs b/ErsatzTV.Application/FFmpegProfiles/Commands/UpdateFFmpegSettingsHandler.cs index fbcb2dc8f..95fdc53da 100644 --- a/ErsatzTV.Application/FFmpegProfiles/Commands/UpdateFFmpegSettingsHandler.cs +++ b/ErsatzTV.Application/FFmpegProfiles/Commands/UpdateFFmpegSettingsHandler.cs @@ -86,35 +86,25 @@ namespace ErsatzTV.Application.FFmpegProfiles.Commands private async Task ApplyUpdate(UpdateFFmpegSettings request) { - await Upsert(ConfigElementKey.FFmpegPath, request.Settings.FFmpegPath); - await Upsert(ConfigElementKey.FFprobePath, request.Settings.FFprobePath); - await Upsert(ConfigElementKey.FFmpegDefaultProfileId, request.Settings.DefaultFFmpegProfileId.ToString()); - await Upsert(ConfigElementKey.FFmpegSaveReports, request.Settings.SaveReports.ToString()); + await _configElementRepository.Upsert(ConfigElementKey.FFmpegPath, request.Settings.FFmpegPath); + await _configElementRepository.Upsert(ConfigElementKey.FFprobePath, request.Settings.FFprobePath); + await _configElementRepository.Upsert( + ConfigElementKey.FFmpegDefaultProfileId, + request.Settings.DefaultFFmpegProfileId.ToString()); + await _configElementRepository.Upsert( + ConfigElementKey.FFmpegSaveReports, + request.Settings.SaveReports.ToString()); if (request.Settings.SaveReports && !Directory.Exists(FileSystemLayout.FFmpegReportsFolder)) { Directory.CreateDirectory(FileSystemLayout.FFmpegReportsFolder); } - await Upsert(ConfigElementKey.FFmpegPreferredLanguageCode, request.Settings.PreferredLanguageCode); + await _configElementRepository.Upsert( + ConfigElementKey.FFmpegPreferredLanguageCode, + request.Settings.PreferredLanguageCode); return Unit.Default; } - - private async Task Upsert(ConfigElementKey key, string value) - { - Option maybeElement = await _configElementRepository.Get(key); - await maybeElement.Match( - ce => - { - ce.Value = value; - return _configElementRepository.Update(ce); - }, - () => - { - var ce = new ConfigElement { Key = key.Key, Value = value }; - return _configElementRepository.Add(ce); - }); - } } } diff --git a/ErsatzTV.Application/FFmpegProfiles/Queries/GetAllFFmpegProfilesHandler.cs b/ErsatzTV.Application/FFmpegProfiles/Queries/GetAllFFmpegProfilesHandler.cs index a28778269..7a1a6f36f 100644 --- a/ErsatzTV.Application/FFmpegProfiles/Queries/GetAllFFmpegProfilesHandler.cs +++ b/ErsatzTV.Application/FFmpegProfiles/Queries/GetAllFFmpegProfilesHandler.cs @@ -2,22 +2,30 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; +using LanguageExt; using MediatR; +using Microsoft.EntityFrameworkCore; using static ErsatzTV.Application.FFmpegProfiles.Mapper; namespace ErsatzTV.Application.FFmpegProfiles.Queries { public class GetAllFFmpegProfilesHandler : IRequestHandler> { - private readonly IFFmpegProfileRepository _ffmpegProfileRepository; + private readonly IDbContextFactory _dbContextFactory; - public GetAllFFmpegProfilesHandler(IFFmpegProfileRepository ffmpegProfileRepository) => - _ffmpegProfileRepository = ffmpegProfileRepository; + public GetAllFFmpegProfilesHandler(IDbContextFactory dbContextFactory) => + _dbContextFactory = dbContextFactory; public async Task> Handle( GetAllFFmpegProfiles request, - CancellationToken cancellationToken) => - (await _ffmpegProfileRepository.GetAll()).Map(ProjectToViewModel).ToList(); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + return await dbContext.FFmpegProfiles + .Include(p => p.Resolution) + .ToListAsync(cancellationToken) + .Map(list => list.Map(ProjectToViewModel).ToList()); + } } } diff --git a/ErsatzTV.Application/FFmpegProfiles/Queries/GetFFmpegProfileByIdHandler.cs b/ErsatzTV.Application/FFmpegProfiles/Queries/GetFFmpegProfileByIdHandler.cs index a4e6ecd48..239412ac8 100644 --- a/ErsatzTV.Application/FFmpegProfiles/Queries/GetFFmpegProfileByIdHandler.cs +++ b/ErsatzTV.Application/FFmpegProfiles/Queries/GetFFmpegProfileByIdHandler.cs @@ -1,23 +1,30 @@ using System.Threading; using System.Threading.Tasks; -using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; using MediatR; +using Microsoft.EntityFrameworkCore; using static ErsatzTV.Application.FFmpegProfiles.Mapper; namespace ErsatzTV.Application.FFmpegProfiles.Queries { public class GetFFmpegProfileByIdHandler : IRequestHandler> { - private readonly IFFmpegProfileRepository _ffmpegProfileRepository; + private readonly IDbContextFactory _dbContextFactory; - public GetFFmpegProfileByIdHandler(IFFmpegProfileRepository ffmpegProfileRepository) => - _ffmpegProfileRepository = ffmpegProfileRepository; + public GetFFmpegProfileByIdHandler(IDbContextFactory dbContextFactory) => + _dbContextFactory = dbContextFactory; - public Task> Handle( + public async Task> Handle( GetFFmpegProfileById request, - CancellationToken cancellationToken) => - _ffmpegProfileRepository.Get(request.Id) + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + return await dbContext.FFmpegProfiles + .Include(p => p.Resolution) + .SelectOneAsync(p => p.Id, p => p.Id == request.Id) .MapT(ProjectToViewModel); + } } } diff --git a/ErsatzTV.Application/HDHR/Commands/UpdateHDHRTunerCountHandler.cs b/ErsatzTV.Application/HDHR/Commands/UpdateHDHRTunerCountHandler.cs index 7186ffc1d..4a04233c5 100644 --- a/ErsatzTV.Application/HDHR/Commands/UpdateHDHRTunerCountHandler.cs +++ b/ErsatzTV.Application/HDHR/Commands/UpdateHDHRTunerCountHandler.cs @@ -19,27 +19,14 @@ namespace ErsatzTV.Application.HDHR.Commands UpdateHDHRTunerCount request, CancellationToken cancellationToken) => Validate(request) - .MapT(_ => Upsert(ConfigElementKey.HDHRTunerCount, request.TunerCount.ToString())) + .MapT(_ => _configElementRepository.Upsert(ConfigElementKey.HDHRTunerCount, request.TunerCount.ToString())) .Bind(v => v.ToEitherAsync()); - private Task> Validate(UpdateHDHRTunerCount request) => + private static Task> Validate(UpdateHDHRTunerCount request) => Optional(request.TunerCount) .Filter(tc => tc > 0) .Map(_ => Unit.Default) .ToValidation("Tuner count must be greater than zero") .AsTask(); - - private Task Upsert(ConfigElementKey key, string value) => - _configElementRepository.Get(key).Match( - ce => - { - ce.Value = value; - return _configElementRepository.Update(ce); - }, - () => - { - var ce = new ConfigElement { Key = key.Key, Value = value }; - return _configElementRepository.Add(ce); - }).ToUnit(); } } diff --git a/ErsatzTV.Application/MediaCards/Queries/GetCollectionCardsHandler.cs b/ErsatzTV.Application/MediaCards/Queries/GetCollectionCardsHandler.cs index 88d023b86..50b8f17a8 100644 --- a/ErsatzTV.Application/MediaCards/Queries/GetCollectionCardsHandler.cs +++ b/ErsatzTV.Application/MediaCards/Queries/GetCollectionCardsHandler.cs @@ -3,23 +3,26 @@ using System.Threading.Tasks; using ErsatzTV.Core; using ErsatzTV.Core.Domain; using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; using MediatR; +using Microsoft.EntityFrameworkCore; using static ErsatzTV.Application.MediaCards.Mapper; namespace ErsatzTV.Application.MediaCards.Queries { - public class GetCollectionCardsHandler : IRequestHandler> + public class GetCollectionCardsHandler : + IRequestHandler> { - private readonly IMediaCollectionRepository _collectionRepository; + private readonly IDbContextFactory _dbContextFactory; private readonly IMediaSourceRepository _mediaSourceRepository; public GetCollectionCardsHandler( - IMediaCollectionRepository collectionRepository, + IDbContextFactory dbContextFactory, IMediaSourceRepository mediaSourceRepository) { - _collectionRepository = collectionRepository; + _dbContextFactory = dbContextFactory; _mediaSourceRepository = mediaSourceRepository; } @@ -27,14 +30,57 @@ namespace ErsatzTV.Application.MediaCards.Queries GetCollectionCards request, CancellationToken cancellationToken) { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + Option maybeJellyfin = await _mediaSourceRepository.GetAllJellyfin() .Map(list => list.HeadOrNone()); Option maybeEmby = await _mediaSourceRepository.GetAllEmby() .Map(list => list.HeadOrNone()); - return await _collectionRepository - .GetCollectionWithItemsUntracked(request.Id) + return await dbContext.Collections + .AsNoTracking() + .Include(c => c.CollectionItems) + .Include(c => c.MediaItems) + .ThenInclude(i => i.LibraryPath) + .Include(c => c.MediaItems) + .ThenInclude(i => (i as Movie).MovieMetadata) + .ThenInclude(mm => mm.Artwork) + .Include(c => c.MediaItems) + .ThenInclude(i => (i as Artist).ArtistMetadata) + .ThenInclude(mvm => mvm.Artwork) + .Include(c => c.MediaItems) + .ThenInclude(i => (i as MusicVideo).MusicVideoMetadata) + .ThenInclude(mvm => mvm.Artwork) + .Include(c => c.MediaItems) + .ThenInclude(i => (i as MusicVideo).Artist) + .ThenInclude(a => a.ArtistMetadata) + .Include(c => c.MediaItems) + .ThenInclude(i => (i as Show).ShowMetadata) + .ThenInclude(sm => sm.Artwork) + .Include(c => c.MediaItems) + .ThenInclude(i => (i as Season).SeasonMetadata) + .ThenInclude(sm => sm.Artwork) + .Include(c => c.MediaItems) + .ThenInclude(i => (i as Season).Show) + .ThenInclude(s => s.ShowMetadata) + .Include(c => c.MediaItems) + .ThenInclude(i => (i as Episode).EpisodeMetadata) + .ThenInclude(em => em.Artwork) + .Include(c => c.MediaItems) + .ThenInclude(i => (i as Episode).EpisodeMetadata) + .ThenInclude(em => em.Directors) + .Include(c => c.MediaItems) + .ThenInclude(i => (i as Episode).EpisodeMetadata) + .ThenInclude(em => em.Writers) + .Include(c => c.MediaItems) + .ThenInclude(i => (i as Episode).Season) + .ThenInclude(s => s.Show) + .ThenInclude(s => s.ShowMetadata) + .Include(c => c.MediaItems) + .ThenInclude(i => (i as Episode).Season) + .ThenInclude(s => s.SeasonMetadata) + .SelectOneAsync(c => c.Id, c => c.Id == request.Id) .Map(c => c.ToEither(BaseError.New("Unable to load collection"))) .MapT(c => ProjectToViewModel(c, maybeJellyfin, maybeEmby)); } diff --git a/ErsatzTV.Application/MediaCollections/Commands/AddArtistToCollectionHandler.cs b/ErsatzTV.Application/MediaCollections/Commands/AddArtistToCollectionHandler.cs index 4f8ba428f..8406a2328 100644 --- a/ErsatzTV.Application/MediaCollections/Commands/AddArtistToCollectionHandler.cs +++ b/ErsatzTV.Application/MediaCollections/Commands/AddArtistToCollectionHandler.cs @@ -5,41 +5,47 @@ using ErsatzTV.Application.Playouts.Commands; using ErsatzTV.Core; using ErsatzTV.Core.Domain; using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; +using Microsoft.EntityFrameworkCore; namespace ErsatzTV.Application.MediaCollections.Commands { - public class - AddArtistToCollectionHandler : MediatR.IRequestHandler> + public class AddArtistToCollectionHandler : + MediatR.IRequestHandler> { - private readonly IArtistRepository _artistRepository; private readonly ChannelWriter _channel; + private readonly IDbContextFactory _dbContextFactory; private readonly IMediaCollectionRepository _mediaCollectionRepository; public AddArtistToCollectionHandler( + IDbContextFactory dbContextFactory, IMediaCollectionRepository mediaCollectionRepository, - IArtistRepository artistRepository, ChannelWriter channel) { + _dbContextFactory = dbContextFactory; _mediaCollectionRepository = mediaCollectionRepository; - _artistRepository = artistRepository; _channel = channel; } - public Task> Handle( + public async Task> Handle( AddArtistToCollection request, - CancellationToken cancellationToken) => - Validate(request) - .MapT(_ => ApplyAddArtistRequest(request)) - .Bind(v => v.ToEitherAsync()); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + Validation validation = await Validate(dbContext, request); + return await validation.Apply(parameters => ApplyAddArtistRequest(dbContext, parameters)); + } - private async Task ApplyAddArtistRequest(AddArtistToCollection request) + private async Task ApplyAddArtistRequest(TvContext dbContext, Parameters parameters) { - if (await _mediaCollectionRepository.AddMediaItem(request.CollectionId, request.ArtistId)) + parameters.Collection.MediaItems.Add(parameters.Artist); + if (await dbContext.SaveChangesAsync() > 0) { // rebuild all playouts that use this collection foreach (int playoutId in await _mediaCollectionRepository - .PlayoutIdsUsingCollection(request.CollectionId)) + .PlayoutIdsUsingCollection(parameters.Collection.Id)) { await _channel.WriteAsync(new BuildPlayout(playoutId, true)); } @@ -48,21 +54,27 @@ namespace ErsatzTV.Application.MediaCollections.Commands return Unit.Default; } - private async Task> Validate(AddArtistToCollection request) => - (await CollectionMustExist(request), await ValidateArtist(request)) - .Apply((_, _) => Unit.Default); + private static async Task> Validate( + TvContext dbContext, + AddArtistToCollection request) => + (await CollectionMustExist(dbContext, request), await ValidateArtist(dbContext, request)) + .Apply((collection, artist) => new Parameters(collection, artist)); - private Task> CollectionMustExist(AddArtistToCollection request) => - _mediaCollectionRepository.GetCollectionWithItems(request.CollectionId) - .MapT(_ => Unit.Default) - .Map(v => v.ToValidation("Collection does not exist.")); + private static Task> CollectionMustExist( + TvContext dbContext, + AddArtistToCollection request) => + dbContext.Collections + .Include(c => c.MediaItems) + .SelectOneAsync(c => c.Id, c => c.Id == request.CollectionId) + .Map(o => o.ToValidation("Collection does not exist.")); - private Task> ValidateArtist(AddArtistToCollection request) => - LoadArtist(request) - .MapT(_ => Unit.Default) - .Map(v => v.ToValidation("Music video does not exist")); + private static Task> ValidateArtist( + TvContext dbContext, + AddArtistToCollection request) => + dbContext.Artists + .SelectOneAsync(a => a.Id, a => a.Id == request.ArtistId) + .Map(o => o.ToValidation("Music video does not exist")); - private Task> LoadArtist(AddArtistToCollection request) => - _artistRepository.GetArtist(request.ArtistId); + private record Parameters(Collection Collection, Artist Artist); } } diff --git a/ErsatzTV.Application/MediaCollections/Commands/AddEpisodeToCollectionHandler.cs b/ErsatzTV.Application/MediaCollections/Commands/AddEpisodeToCollectionHandler.cs index 8b41da6cc..625d013e2 100644 --- a/ErsatzTV.Application/MediaCollections/Commands/AddEpisodeToCollectionHandler.cs +++ b/ErsatzTV.Application/MediaCollections/Commands/AddEpisodeToCollectionHandler.cs @@ -3,42 +3,49 @@ using System.Threading.Channels; using System.Threading.Tasks; using ErsatzTV.Application.Playouts.Commands; using ErsatzTV.Core; +using ErsatzTV.Core.Domain; using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; +using Microsoft.EntityFrameworkCore; namespace ErsatzTV.Application.MediaCollections.Commands { - public class - AddEpisodeToCollectionHandler : MediatR.IRequestHandler> + public class AddEpisodeToCollectionHandler : + MediatR.IRequestHandler> { private readonly ChannelWriter _channel; + private readonly IDbContextFactory _dbContextFactory; private readonly IMediaCollectionRepository _mediaCollectionRepository; - private readonly ITelevisionRepository _televisionRepository; public AddEpisodeToCollectionHandler( + IDbContextFactory dbContextFactory, IMediaCollectionRepository mediaCollectionRepository, - ITelevisionRepository televisionRepository, ChannelWriter channel) { + _dbContextFactory = dbContextFactory; _mediaCollectionRepository = mediaCollectionRepository; - _televisionRepository = televisionRepository; _channel = channel; } - public Task> Handle( + public async Task> Handle( AddEpisodeToCollection request, - CancellationToken cancellationToken) => - Validate(request) - .MapT(_ => ApplyAddTelevisionEpisodeRequest(request)) - .Bind(v => v.ToEitherAsync()); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + Validation validation = await Validate(dbContext, request); + return await validation.Apply(parameters => ApplyAddTelevisionEpisodeRequest(dbContext, parameters)); + } - private async Task ApplyAddTelevisionEpisodeRequest(AddEpisodeToCollection request) + private async Task ApplyAddTelevisionEpisodeRequest(TvContext dbContext, Parameters parameters) { - if (await _mediaCollectionRepository.AddMediaItem(request.CollectionId, request.EpisodeId)) + parameters.Collection.MediaItems.Add(parameters.Episode); + if (await dbContext.SaveChangesAsync() > 0) { // rebuild all playouts that use this collection foreach (int playoutId in await _mediaCollectionRepository - .PlayoutIdsUsingCollection(request.CollectionId)) + .PlayoutIdsUsingCollection(parameters.Collection.Id)) { await _channel.WriteAsync(new BuildPlayout(playoutId, true)); } @@ -47,21 +54,27 @@ namespace ErsatzTV.Application.MediaCollections.Commands return Unit.Default; } - private async Task> Validate(AddEpisodeToCollection request) => - (await CollectionMustExist(request), await ValidateEpisode(request)) - .Apply((_, _) => Unit.Default); + private static async Task> Validate( + TvContext dbContext, + AddEpisodeToCollection request) => + (await CollectionMustExist(dbContext, request), await ValidateEpisode(dbContext, request)) + .Apply((collection, episode) => new Parameters(collection, episode)); - private Task> CollectionMustExist(AddEpisodeToCollection request) => - _mediaCollectionRepository.Get(request.CollectionId) - .MapT(_ => Unit.Default) - .Map(v => v.ToValidation("Collection does not exist.")); + private static Task> CollectionMustExist( + TvContext dbContext, + AddEpisodeToCollection request) => + dbContext.Collections + .Include(c => c.MediaItems) + .SelectOneAsync(c => c.Id, c => c.Id == request.CollectionId) + .Map(o => o.ToValidation("Collection does not exist.")); - private Task> ValidateEpisode(AddEpisodeToCollection request) => - LoadTelevisionEpisode(request) - .MapT(_ => Unit.Default) - .Map(v => v.ToValidation("Episode does not exist")); + private static Task> ValidateEpisode( + TvContext dbContext, + AddEpisodeToCollection request) => + dbContext.Episodes + .SelectOneAsync(e => e.Id, e => e.Id == request.EpisodeId) + .Map(o => o.ToValidation("Episode does not exist")); - private Task> LoadTelevisionEpisode(AddEpisodeToCollection request) => - _televisionRepository.GetEpisode(request.EpisodeId).MapT(e => e.Id); + private record Parameters(Collection Collection, Episode Episode); } } diff --git a/ErsatzTV.Application/MediaCollections/Commands/AddItemsToCollectionHandler.cs b/ErsatzTV.Application/MediaCollections/Commands/AddItemsToCollectionHandler.cs index 5c214de71..428945b93 100644 --- a/ErsatzTV.Application/MediaCollections/Commands/AddItemsToCollectionHandler.cs +++ b/ErsatzTV.Application/MediaCollections/Commands/AddItemsToCollectionHandler.cs @@ -1,43 +1,54 @@ -using System.Linq; +using System.Collections.Generic; +using System.Linq; using System.Threading; using System.Threading.Channels; using System.Threading.Tasks; using ErsatzTV.Application.Playouts.Commands; using ErsatzTV.Core; +using ErsatzTV.Core.Domain; using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; +using Microsoft.EntityFrameworkCore; using static LanguageExt.Prelude; namespace ErsatzTV.Application.MediaCollections.Commands { - public class - AddItemsToCollectionHandler : MediatR.IRequestHandler> + public class AddItemsToCollectionHandler : + MediatR.IRequestHandler> { private readonly ChannelWriter _channel; + private readonly IDbContextFactory _dbContextFactory; private readonly IMediaCollectionRepository _mediaCollectionRepository; private readonly IMovieRepository _movieRepository; private readonly ITelevisionRepository _televisionRepository; public AddItemsToCollectionHandler( + IDbContextFactory dbContextFactory, IMediaCollectionRepository mediaCollectionRepository, IMovieRepository movieRepository, ITelevisionRepository televisionRepository, ChannelWriter channel) { + _dbContextFactory = dbContextFactory; _mediaCollectionRepository = mediaCollectionRepository; _movieRepository = movieRepository; _televisionRepository = televisionRepository; _channel = channel; } - public Task> Handle( + public async Task> Handle( AddItemsToCollection request, - CancellationToken cancellationToken) => - Validate(request) - .MapT(_ => ApplyAddItemsRequest(request)) - .Bind(v => v.ToEitherAsync()); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + + Validation validation = await Validate(dbContext, request); + return await validation.Apply(c => ApplyAddItemsRequest(dbContext, c, request)); + } - private async Task ApplyAddItemsRequest(AddItemsToCollection request) + private async Task ApplyAddItemsRequest(TvContext dbContext, Collection collection, AddItemsToCollection request) { var allItems = request.MovieIds .Append(request.ShowIds) @@ -46,7 +57,14 @@ namespace ErsatzTV.Application.MediaCollections.Commands .Append(request.MusicVideoIds) .ToList(); - if (await _mediaCollectionRepository.AddMediaItems(request.CollectionId, allItems)) + var toAddIds = allItems.Where(item => collection.MediaItems.All(mi => mi.Id != item)).ToList(); + List toAdd = await dbContext.MediaItems + .Filter(mi => toAddIds.Contains(mi.Id)) + .ToListAsync(); + + collection.MediaItems.AddRange(toAdd); + + if (await dbContext.SaveChangesAsync() > 0) { // rebuild all playouts that use this collection foreach (int playoutId in await _mediaCollectionRepository @@ -59,15 +77,20 @@ namespace ErsatzTV.Application.MediaCollections.Commands return Unit.Default; } - private async Task> Validate(AddItemsToCollection request) => - (await CollectionMustExist(request), await ValidateMovies(request), await ValidateShows(request), + private async Task> Validate(TvContext dbContext, AddItemsToCollection request) => + (await CollectionMustExist(dbContext, request), + await ValidateMovies(request), + await ValidateShows(request), await ValidateEpisodes(request)) - .Apply((_, _, _, _) => Unit.Default); + .Apply((collection, _, _, _) => collection); - private Task> CollectionMustExist(AddItemsToCollection request) => - _mediaCollectionRepository.GetCollectionWithItems(request.CollectionId) - .MapT(_ => Unit.Default) - .Map(v => v.ToValidation("Collection does not exist.")); + private static Task> CollectionMustExist( + TvContext dbContext, + AddItemsToCollection request) => + dbContext.Collections + .Include(c => c.MediaItems) + .SelectOneAsync(c => c.Id, c => c.Id == request.CollectionId) + .Map(o => o.ToValidation("Collection does not exist.")); private Task> ValidateMovies(AddItemsToCollection request) => _movieRepository.AllMoviesExist(request.MovieIds) @@ -88,6 +111,6 @@ namespace ErsatzTV.Application.MediaCollections.Commands .Map(Optional) .Filter(v => v == true) .MapT(_ => Unit.Default) - .Map(v => v.ToValidation("Show does not exist")); + .Map(v => v.ToValidation("Episode does not exist")); } } diff --git a/ErsatzTV.Application/MediaCollections/Commands/AddMovieToCollectionHandler.cs b/ErsatzTV.Application/MediaCollections/Commands/AddMovieToCollectionHandler.cs index 3f8d0225a..7c92ec84b 100644 --- a/ErsatzTV.Application/MediaCollections/Commands/AddMovieToCollectionHandler.cs +++ b/ErsatzTV.Application/MediaCollections/Commands/AddMovieToCollectionHandler.cs @@ -5,41 +5,47 @@ using ErsatzTV.Application.Playouts.Commands; using ErsatzTV.Core; using ErsatzTV.Core.Domain; using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; +using Microsoft.EntityFrameworkCore; namespace ErsatzTV.Application.MediaCollections.Commands { - public class - AddMovieToCollectionHandler : MediatR.IRequestHandler> + public class AddMovieToCollectionHandler : + MediatR.IRequestHandler> { private readonly ChannelWriter _channel; + private readonly IDbContextFactory _dbContextFactory; private readonly IMediaCollectionRepository _mediaCollectionRepository; - private readonly IMovieRepository _movieRepository; public AddMovieToCollectionHandler( + IDbContextFactory dbContextFactory, IMediaCollectionRepository mediaCollectionRepository, - IMovieRepository movieRepository, ChannelWriter channel) { + _dbContextFactory = dbContextFactory; _mediaCollectionRepository = mediaCollectionRepository; - _movieRepository = movieRepository; _channel = channel; } - public Task> Handle( + public async Task> Handle( AddMovieToCollection request, - CancellationToken cancellationToken) => - Validate(request) - .MapT(_ => ApplyAddMoviesRequest(request)) - .Bind(v => v.ToEitherAsync()); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + Validation validation = await Validate(dbContext, request); + return await validation.Apply(parameters => ApplyAddMovieRequest(dbContext, parameters)); + } - private async Task ApplyAddMoviesRequest(AddMovieToCollection request) + private async Task ApplyAddMovieRequest(TvContext dbContext, Parameters parameters) { - if (await _mediaCollectionRepository.AddMediaItem(request.CollectionId, request.MovieId)) + parameters.Collection.MediaItems.Add(parameters.Movie); + if (await dbContext.SaveChangesAsync() > 0) { // rebuild all playouts that use this collection foreach (int playoutId in await _mediaCollectionRepository - .PlayoutIdsUsingCollection(request.CollectionId)) + .PlayoutIdsUsingCollection(parameters.Collection.Id)) { await _channel.WriteAsync(new BuildPlayout(playoutId, true)); } @@ -48,21 +54,27 @@ namespace ErsatzTV.Application.MediaCollections.Commands return Unit.Default; } - private async Task> Validate(AddMovieToCollection request) => - (await CollectionMustExist(request), await ValidateMovies(request)) - .Apply((_, _) => Unit.Default); + private static async Task> Validate( + TvContext dbContext, + AddMovieToCollection request) => + (await CollectionMustExist(dbContext, request), await ValidateMovie(dbContext, request)) + .Apply((collection, episode) => new Parameters(collection, episode)); - private Task> CollectionMustExist(AddMovieToCollection request) => - _mediaCollectionRepository.GetCollectionWithItems(request.CollectionId) - .MapT(_ => Unit.Default) - .Map(v => v.ToValidation("Collection does not exist.")); + private static Task> CollectionMustExist( + TvContext dbContext, + AddMovieToCollection request) => + dbContext.Collections + .Include(c => c.MediaItems) + .SelectOneAsync(c => c.Id, c => c.Id == request.CollectionId) + .Map(o => o.ToValidation("Collection does not exist.")); - private Task> ValidateMovies(AddMovieToCollection request) => - LoadMovie(request) - .MapT(_ => Unit.Default) - .Map(v => v.ToValidation("Movie does not exist")); + private static Task> ValidateMovie( + TvContext dbContext, + AddMovieToCollection request) => + dbContext.Movies + .SelectOneAsync(m => m.Id, e => e.Id == request.MovieId) + .Map(o => o.ToValidation("Movie does not exist")); - private Task> LoadMovie(AddMovieToCollection request) => - _movieRepository.GetMovie(request.MovieId); + private record Parameters(Collection Collection, Movie Movie); } } diff --git a/ErsatzTV.Application/MediaCollections/Commands/AddMusicVideoToCollectionHandler.cs b/ErsatzTV.Application/MediaCollections/Commands/AddMusicVideoToCollectionHandler.cs index 4dfea21e1..b21b3408f 100644 --- a/ErsatzTV.Application/MediaCollections/Commands/AddMusicVideoToCollectionHandler.cs +++ b/ErsatzTV.Application/MediaCollections/Commands/AddMusicVideoToCollectionHandler.cs @@ -5,41 +5,47 @@ using ErsatzTV.Application.Playouts.Commands; using ErsatzTV.Core; using ErsatzTV.Core.Domain; using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; +using Microsoft.EntityFrameworkCore; namespace ErsatzTV.Application.MediaCollections.Commands { - public class - AddMusicVideoToCollectionHandler : MediatR.IRequestHandler> + public class AddMusicVideoToCollectionHandler : + MediatR.IRequestHandler> { private readonly ChannelWriter _channel; + private readonly IDbContextFactory _dbContextFactory; private readonly IMediaCollectionRepository _mediaCollectionRepository; - private readonly IMusicVideoRepository _musicVideoRepository; public AddMusicVideoToCollectionHandler( + IDbContextFactory dbContextFactory, IMediaCollectionRepository mediaCollectionRepository, - IMusicVideoRepository musicVideoRepository, ChannelWriter channel) { + _dbContextFactory = dbContextFactory; _mediaCollectionRepository = mediaCollectionRepository; - _musicVideoRepository = musicVideoRepository; _channel = channel; } - public Task> Handle( + public async Task> Handle( AddMusicVideoToCollection request, - CancellationToken cancellationToken) => - Validate(request) - .MapT(_ => ApplyAddMusicVideoRequest(request)) - .Bind(v => v.ToEitherAsync()); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + Validation validation = await Validate(dbContext, request); + return await validation.Apply(parameters => ApplyAddMusicVideoRequest(dbContext, parameters)); + } - private async Task ApplyAddMusicVideoRequest(AddMusicVideoToCollection request) + private async Task ApplyAddMusicVideoRequest(TvContext dbContext, Parameters parameters) { - if (await _mediaCollectionRepository.AddMediaItem(request.CollectionId, request.MusicVideoId)) + parameters.Collection.MediaItems.Add(parameters.MusicVideo); + if (await dbContext.SaveChangesAsync() > 0) { // rebuild all playouts that use this collection foreach (int playoutId in await _mediaCollectionRepository - .PlayoutIdsUsingCollection(request.CollectionId)) + .PlayoutIdsUsingCollection(parameters.Collection.Id)) { await _channel.WriteAsync(new BuildPlayout(playoutId, true)); } @@ -48,21 +54,27 @@ namespace ErsatzTV.Application.MediaCollections.Commands return Unit.Default; } - private async Task> Validate(AddMusicVideoToCollection request) => - (await CollectionMustExist(request), await ValidateMusicVideo(request)) - .Apply((_, _) => Unit.Default); + private static async Task> Validate( + TvContext dbContext, + AddMusicVideoToCollection request) => + (await CollectionMustExist(dbContext, request), await ValidateMusicVideo(dbContext, request)) + .Apply((collection, episode) => new Parameters(collection, episode)); - private Task> CollectionMustExist(AddMusicVideoToCollection request) => - _mediaCollectionRepository.GetCollectionWithItems(request.CollectionId) - .MapT(_ => Unit.Default) - .Map(v => v.ToValidation("Collection does not exist.")); + private static Task> CollectionMustExist( + TvContext dbContext, + AddMusicVideoToCollection request) => + dbContext.Collections + .Include(c => c.MediaItems) + .SelectOneAsync(c => c.Id, c => c.Id == request.CollectionId) + .Map(o => o.ToValidation("Collection does not exist.")); - private Task> ValidateMusicVideo(AddMusicVideoToCollection request) => - LoadMusicVideo(request) - .MapT(_ => Unit.Default) - .Map(v => v.ToValidation("Music video does not exist")); + private static Task> ValidateMusicVideo( + TvContext dbContext, + AddMusicVideoToCollection request) => + dbContext.MusicVideos + .SelectOneAsync(m => m.Id, e => e.Id == request.MusicVideoId) + .Map(o => o.ToValidation("MusicVideo does not exist")); - private Task> LoadMusicVideo(AddMusicVideoToCollection request) => - _musicVideoRepository.GetMusicVideo(request.MusicVideoId); + private record Parameters(Collection Collection, MusicVideo MusicVideo); } } diff --git a/ErsatzTV.Application/MediaCollections/Commands/AddSeasonToCollectionHandler.cs b/ErsatzTV.Application/MediaCollections/Commands/AddSeasonToCollectionHandler.cs index b677da943..f5d3e3952 100644 --- a/ErsatzTV.Application/MediaCollections/Commands/AddSeasonToCollectionHandler.cs +++ b/ErsatzTV.Application/MediaCollections/Commands/AddSeasonToCollectionHandler.cs @@ -5,41 +5,47 @@ using ErsatzTV.Application.Playouts.Commands; using ErsatzTV.Core; using ErsatzTV.Core.Domain; using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; +using Microsoft.EntityFrameworkCore; namespace ErsatzTV.Application.MediaCollections.Commands { - public class - AddSeasonToCollectionHandler : MediatR.IRequestHandler> + public class AddSeasonToCollectionHandler : + MediatR.IRequestHandler> { private readonly ChannelWriter _channel; + private readonly IDbContextFactory _dbContextFactory; private readonly IMediaCollectionRepository _mediaCollectionRepository; - private readonly ITelevisionRepository _televisionRepository; public AddSeasonToCollectionHandler( + IDbContextFactory dbContextFactory, IMediaCollectionRepository mediaCollectionRepository, - ITelevisionRepository televisionRepository, ChannelWriter channel) { + _dbContextFactory = dbContextFactory; _mediaCollectionRepository = mediaCollectionRepository; - _televisionRepository = televisionRepository; _channel = channel; } - public Task> Handle( + public async Task> Handle( AddSeasonToCollection request, - CancellationToken cancellationToken) => - Validate(request) - .MapT(_ => ApplyAddTelevisionSeasonRequest(request)) - .Bind(v => v.ToEitherAsync()); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + Validation validation = await Validate(dbContext, request); + return await validation.Apply(parameters => ApplyAddSeasonRequest(dbContext, parameters)); + } - private async Task ApplyAddTelevisionSeasonRequest(AddSeasonToCollection request) + private async Task ApplyAddSeasonRequest(TvContext dbContext, Parameters parameters) { - if (await _mediaCollectionRepository.AddMediaItem(request.CollectionId, request.SeasonId)) + parameters.Collection.MediaItems.Add(parameters.Season); + if (await dbContext.SaveChangesAsync() > 0) { // rebuild all playouts that use this collection foreach (int playoutId in await _mediaCollectionRepository - .PlayoutIdsUsingCollection(request.CollectionId)) + .PlayoutIdsUsingCollection(parameters.Collection.Id)) { await _channel.WriteAsync(new BuildPlayout(playoutId, true)); } @@ -48,22 +54,27 @@ namespace ErsatzTV.Application.MediaCollections.Commands return Unit.Default; } - private async Task> Validate(AddSeasonToCollection request) => - (await CollectionMustExist(request), await ValidateSeason(request)) - .Apply((_, _) => Unit.Default); - - private Task> CollectionMustExist(AddSeasonToCollection request) => - _mediaCollectionRepository.GetCollectionWithItems(request.CollectionId) - .MapT(_ => Unit.Default) - .Map(v => v.ToValidation("Collection does not exist.")); + private static async Task> Validate( + TvContext dbContext, + AddSeasonToCollection request) => + (await CollectionMustExist(dbContext, request), await ValidateSeason(dbContext, request)) + .Apply((collection, episode) => new Parameters(collection, episode)); - private Task> ValidateSeason(AddSeasonToCollection request) => - LoadTelevisionSeason(request) - .MapT(_ => Unit.Default) - .Map(v => v.ToValidation("Season does not exist")); + private static Task> CollectionMustExist( + TvContext dbContext, + AddSeasonToCollection request) => + dbContext.Collections + .Include(c => c.MediaItems) + .SelectOneAsync(c => c.Id, c => c.Id == request.CollectionId) + .Map(o => o.ToValidation("Collection does not exist.")); - private Task> LoadTelevisionSeason( + private static Task> ValidateSeason( + TvContext dbContext, AddSeasonToCollection request) => - _televisionRepository.GetSeason(request.SeasonId); + dbContext.Seasons + .SelectOneAsync(m => m.Id, e => e.Id == request.SeasonId) + .Map(o => o.ToValidation("Season does not exist")); + + private record Parameters(Collection Collection, Season Season); } } diff --git a/ErsatzTV.Application/MediaCollections/Commands/AddShowToCollectionHandler.cs b/ErsatzTV.Application/MediaCollections/Commands/AddShowToCollectionHandler.cs index de77bacfa..adee60732 100644 --- a/ErsatzTV.Application/MediaCollections/Commands/AddShowToCollectionHandler.cs +++ b/ErsatzTV.Application/MediaCollections/Commands/AddShowToCollectionHandler.cs @@ -5,65 +5,76 @@ using ErsatzTV.Application.Playouts.Commands; using ErsatzTV.Core; using ErsatzTV.Core.Domain; using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; +using Microsoft.EntityFrameworkCore; namespace ErsatzTV.Application.MediaCollections.Commands { - public class AddShowToCollectionHandler : MediatR.IRequestHandler> + public class AddShowToCollectionHandler : + MediatR.IRequestHandler> { private readonly ChannelWriter _channel; + private readonly IDbContextFactory _dbContextFactory; private readonly IMediaCollectionRepository _mediaCollectionRepository; - private readonly ITelevisionRepository _televisionRepository; public AddShowToCollectionHandler( + IDbContextFactory dbContextFactory, IMediaCollectionRepository mediaCollectionRepository, - ITelevisionRepository televisionRepository, ChannelWriter channel) { + _dbContextFactory = dbContextFactory; _mediaCollectionRepository = mediaCollectionRepository; - _televisionRepository = televisionRepository; _channel = channel; } - public Task> Handle( + public async Task> Handle( AddShowToCollection request, - CancellationToken cancellationToken) => - Validate(request) - .MapT(_ => ApplyAddTelevisionShowRequest(request)) - .Bind(v => v.ToEitherAsync()); - - private async Task ApplyAddTelevisionShowRequest(AddShowToCollection request) + CancellationToken cancellationToken) { - var result = new Unit(); + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + Validation validation = await Validate(dbContext, request); + return await validation.Apply(parameters => ApplyAddShowRequest(dbContext, parameters)); + } - if (await _mediaCollectionRepository.AddMediaItem(request.CollectionId, request.ShowId)) + private async Task ApplyAddShowRequest(TvContext dbContext, Parameters parameters) + { + parameters.Collection.MediaItems.Add(parameters.Show); + if (await dbContext.SaveChangesAsync() > 0) { // rebuild all playouts that use this collection foreach (int playoutId in await _mediaCollectionRepository - .PlayoutIdsUsingCollection(request.CollectionId)) + .PlayoutIdsUsingCollection(parameters.Collection.Id)) { await _channel.WriteAsync(new BuildPlayout(playoutId, true)); } } - return result; + return Unit.Default; } - private async Task> Validate(AddShowToCollection request) => - (await CollectionMustExist(request), await ValidateShow(request)) - .Apply((_, _) => Unit.Default); + private static async Task> Validate( + TvContext dbContext, + AddShowToCollection request) => + (await CollectionMustExist(dbContext, request), await ValidateShow(dbContext, request)) + .Apply((collection, episode) => new Parameters(collection, episode)); - private Task> CollectionMustExist(AddShowToCollection request) => - _mediaCollectionRepository.GetCollectionWithItems(request.CollectionId) - .MapT(_ => Unit.Default) - .Map(v => v.ToValidation("Collection does not exist.")); + private static Task> CollectionMustExist( + TvContext dbContext, + AddShowToCollection request) => + dbContext.Collections + .Include(c => c.MediaItems) + .SelectOneAsync(c => c.Id, c => c.Id == request.CollectionId) + .Map(o => o.ToValidation("Collection does not exist.")); - private Task> ValidateShow(AddShowToCollection request) => - LoadTelevisionShow(request) - .MapT(_ => Unit.Default) - .Map(v => v.ToValidation("Show does not exist")); + private static Task> ValidateShow( + TvContext dbContext, + AddShowToCollection request) => + dbContext.Shows + .SelectOneAsync(m => m.Id, e => e.Id == request.ShowId) + .Map(o => o.ToValidation("Show does not exist")); - private Task> LoadTelevisionShow(AddShowToCollection request) => - _televisionRepository.GetShow(request.ShowId); + private record Parameters(Collection Collection, Show Show); } } diff --git a/ErsatzTV.Application/MediaCollections/Commands/CreateCollectionHandler.cs b/ErsatzTV.Application/MediaCollections/Commands/CreateCollectionHandler.cs index 2bb747502..0f02b7dcc 100644 --- a/ErsatzTV.Application/MediaCollections/Commands/CreateCollectionHandler.cs +++ b/ErsatzTV.Application/MediaCollections/Commands/CreateCollectionHandler.cs @@ -1,45 +1,60 @@ using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; using ErsatzTV.Core; using ErsatzTV.Core.Domain; -using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; using LanguageExt; using MediatR; +using Microsoft.EntityFrameworkCore; using static ErsatzTV.Application.MediaCollections.Mapper; using static LanguageExt.Prelude; namespace ErsatzTV.Application.MediaCollections.Commands { - public class - CreateCollectionHandler : IRequestHandler> + public class CreateCollectionHandler : + IRequestHandler> { - private readonly IMediaCollectionRepository _mediaCollectionRepository; + private readonly IDbContextFactory _dbContextFactory; - public CreateCollectionHandler(IMediaCollectionRepository mediaCollectionRepository) => - _mediaCollectionRepository = mediaCollectionRepository; + public CreateCollectionHandler(IDbContextFactory dbContextFactory) => + _dbContextFactory = dbContextFactory; - public Task> Handle( + public async Task> Handle( CreateCollection request, - CancellationToken cancellationToken) => - Validate(request).MapT(PersistCollection).Bind(v => v.ToEitherAsync()); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + Validation validation = await Validate(dbContext, request); + return await validation.Apply(c => PersistCollection(dbContext, c)); + } - private Task PersistCollection(Collection c) => - _mediaCollectionRepository.Add(c).Map(ProjectToViewModel); + private static async Task PersistCollection( + TvContext dbContext, + Collection collection) + { + await dbContext.Collections.AddAsync(collection); + await dbContext.SaveChangesAsync(); + return ProjectToViewModel(collection); + } - private Task> Validate(CreateCollection request) => - ValidateName(request).MapT( + private static Task> Validate( + TvContext dbContext, + CreateCollection request) => + ValidateName(dbContext, request).MapT( name => new Collection { Name = name, MediaItems = new List() }); - private async Task> ValidateName(CreateCollection createCollection) + private static async Task> ValidateName( + TvContext dbContext, + CreateCollection createCollection) { - List allNames = await _mediaCollectionRepository.GetAll() - .Map(list => list.Map(c => c.Name).ToList()); + List allNames = await dbContext.Collections + .Map(c => c.Name) + .ToListAsync(); Validation result1 = createCollection.NotEmpty(c => c.Name) .Bind(_ => createCollection.NotLongerThan(50)(c => c.Name)); diff --git a/ErsatzTV.Application/MediaCollections/Commands/DeleteCollection.cs b/ErsatzTV.Application/MediaCollections/Commands/DeleteCollection.cs index eb8bcbe72..fb0b8f3c1 100644 --- a/ErsatzTV.Application/MediaCollections/Commands/DeleteCollection.cs +++ b/ErsatzTV.Application/MediaCollections/Commands/DeleteCollection.cs @@ -1,9 +1,8 @@ -using System.Threading.Tasks; -using ErsatzTV.Core; +using ErsatzTV.Core; using LanguageExt; using MediatR; namespace ErsatzTV.Application.MediaCollections.Commands { - public record DeleteCollection(int CollectionId) : IRequest>; + public record DeleteCollection(int CollectionId) : IRequest>; } diff --git a/ErsatzTV.Application/MediaCollections/Commands/DeleteCollectionHandler.cs b/ErsatzTV.Application/MediaCollections/Commands/DeleteCollectionHandler.cs index 57e8b2ef4..00f53d3aa 100644 --- a/ErsatzTV.Application/MediaCollections/Commands/DeleteCollectionHandler.cs +++ b/ErsatzTV.Application/MediaCollections/Commands/DeleteCollectionHandler.cs @@ -1,33 +1,42 @@ using System.Threading; using System.Threading.Tasks; using ErsatzTV.Core; -using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Core.Domain; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; -using MediatR; +using Microsoft.EntityFrameworkCore; namespace ErsatzTV.Application.MediaCollections.Commands { - public class DeleteCollectionHandler : IRequestHandler> + public class DeleteCollectionHandler : MediatR.IRequestHandler> { - private readonly IMediaCollectionRepository _mediaCollectionRepository; + private readonly IDbContextFactory _dbContextFactory; - public DeleteCollectionHandler(IMediaCollectionRepository mediaCollectionRepository) => - _mediaCollectionRepository = mediaCollectionRepository; + public DeleteCollectionHandler(IDbContextFactory dbContextFactory) => + _dbContextFactory = dbContextFactory; - public async Task> Handle( + public async Task> Handle( DeleteCollection request, - CancellationToken cancellationToken) => - (await CollectionMustExist(request)) - .Map(DoDeletion) - .ToEither(); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); - private Task DoDeletion(int mediaCollectionId) => _mediaCollectionRepository.Delete(mediaCollectionId); + Validation validation = await CollectionMustExist(dbContext, request); + return await validation.Apply(c => DoDeletion(dbContext, c)); + } - private async Task> CollectionMustExist( - DeleteCollection deleteMediaCollection) => - (await _mediaCollectionRepository.Get(deleteMediaCollection.CollectionId)) - .ToValidation( - $"Collection {deleteMediaCollection.CollectionId} does not exist.") - .Map(c => c.Id); + private static Task DoDeletion(TvContext dbContext, Collection collection) + { + dbContext.Collections.Remove(collection); + return dbContext.SaveChangesAsync().ToUnit(); + } + + private static Task> CollectionMustExist( + TvContext dbContext, + DeleteCollection request) => + dbContext.Collections + .SelectOneAsync(c => c.Id, c => c.Id == request.CollectionId) + .Map(o => o.ToValidation($"Collection {request.CollectionId} does not exist.")); } } diff --git a/ErsatzTV.Application/MediaCollections/Commands/RemoveItemsFromCollectionHandler.cs b/ErsatzTV.Application/MediaCollections/Commands/RemoveItemsFromCollectionHandler.cs index cab1d2a9d..4e932a0f6 100644 --- a/ErsatzTV.Application/MediaCollections/Commands/RemoveItemsFromCollectionHandler.cs +++ b/ErsatzTV.Application/MediaCollections/Commands/RemoveItemsFromCollectionHandler.cs @@ -6,32 +6,41 @@ using ErsatzTV.Application.Playouts.Commands; using ErsatzTV.Core; using ErsatzTV.Core.Domain; using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; +using Microsoft.EntityFrameworkCore; namespace ErsatzTV.Application.MediaCollections.Commands { - public class - RemoveItemsFromCollectionHandler : MediatR.IRequestHandler> + public class RemoveItemsFromCollectionHandler : + MediatR.IRequestHandler> { private readonly ChannelWriter _channel; + private readonly IDbContextFactory _dbContextFactory; private readonly IMediaCollectionRepository _mediaCollectionRepository; public RemoveItemsFromCollectionHandler( + IDbContextFactory dbContextFactory, IMediaCollectionRepository mediaCollectionRepository, ChannelWriter channel) { + _dbContextFactory = dbContextFactory; _mediaCollectionRepository = mediaCollectionRepository; _channel = channel; } - public Task> Handle( + public async Task> Handle( RemoveItemsFromCollection request, - CancellationToken cancellationToken) => - Validate(request) - .MapT(collection => ApplyRemoveItemsRequest(request, collection)) - .Bind(v => v.ToEitherAsync()); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + Validation validation = await Validate(dbContext, request); + return await validation.Apply(c => ApplyRemoveItemsRequest(dbContext, request, c)); + } private async Task ApplyRemoveItemsRequest( + TvContext dbContext, RemoveItemsFromCollection request, Collection collection) { @@ -41,7 +50,7 @@ namespace ErsatzTV.Application.MediaCollections.Commands itemsToRemove.ForEach(m => collection.MediaItems.Remove(m)); - if (itemsToRemove.Any() && await _mediaCollectionRepository.Update(collection)) + if (itemsToRemove.Any() && await dbContext.SaveChangesAsync() > 0) { // rebuild all playouts that use this collection foreach (int playoutId in await _mediaCollectionRepository.PlayoutIdsUsingCollection(collection.Id)) @@ -53,13 +62,17 @@ namespace ErsatzTV.Application.MediaCollections.Commands return Unit.Default; } - private Task> Validate( + private static Task> Validate( + TvContext dbContext, RemoveItemsFromCollection request) => - CollectionMustExist(request); + CollectionMustExist(dbContext, request); - private Task> CollectionMustExist( - RemoveItemsFromCollection updateCollection) => - _mediaCollectionRepository.GetCollectionWithItems(updateCollection.MediaCollectionId) - .Map(v => v.ToValidation("Collection does not exist.")); + private static Task> CollectionMustExist( + TvContext dbContext, + RemoveItemsFromCollection request) => + dbContext.Collections + .Include(c => c.MediaItems) + .SelectOneAsync(c => c.Id, c => c.Id == request.MediaCollectionId) + .Map(o => o.ToValidation("Collection does not exist.")); } } diff --git a/ErsatzTV.Application/MediaCollections/Commands/UpdateCollectionCustomOrderHandler.cs b/ErsatzTV.Application/MediaCollections/Commands/UpdateCollectionCustomOrderHandler.cs index 96937c47b..a40add059 100644 --- a/ErsatzTV.Application/MediaCollections/Commands/UpdateCollectionCustomOrderHandler.cs +++ b/ErsatzTV.Application/MediaCollections/Commands/UpdateCollectionCustomOrderHandler.cs @@ -6,47 +6,60 @@ using ErsatzTV.Application.Playouts.Commands; using ErsatzTV.Core; using ErsatzTV.Core.Domain; using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; +using Microsoft.EntityFrameworkCore; namespace ErsatzTV.Application.MediaCollections.Commands { - public class - UpdateCollectionCustomOrderHandler : MediatR.IRequestHandler> + public class UpdateCollectionCustomOrderHandler : + MediatR.IRequestHandler> { private readonly ChannelWriter _channel; + private readonly IDbContextFactory _dbContextFactory; private readonly IMediaCollectionRepository _mediaCollectionRepository; public UpdateCollectionCustomOrderHandler( + IDbContextFactory dbContextFactory, IMediaCollectionRepository mediaCollectionRepository, ChannelWriter channel) { + _dbContextFactory = dbContextFactory; _mediaCollectionRepository = mediaCollectionRepository; _channel = channel; } - public Task> Handle( + public async Task> Handle( UpdateCollectionCustomOrder request, - CancellationToken cancellationToken) => - Validate(request) - .MapT(c => ApplyUpdateRequest(c, request)) - .Bind(v => v.ToEitherAsync()); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + Validation validation = await Validate(dbContext, request); + return await validation.Apply(c => ApplyUpdateRequest(dbContext, c, request)); + } - private async Task ApplyUpdateRequest(Collection c, UpdateCollectionCustomOrder request) + private async Task ApplyUpdateRequest( + TvContext dbContext, + Collection c, + UpdateCollectionCustomOrder request) { foreach (MediaItemCustomOrder updateItem in request.MediaItemCustomOrders) { - Option maybeCollectionItem = - c.CollectionItems.FirstOrDefault(ci => ci.MediaItemId == updateItem.MediaItemId); + Option maybeCollectionItem = c.CollectionItems + .FirstOrDefault(ci => ci.MediaItemId == updateItem.MediaItemId); - await maybeCollectionItem.IfSomeAsync(ci => ci.CustomIndex = updateItem.CustomIndex); + foreach (CollectionItem collectionItem in maybeCollectionItem) + { + collectionItem.CustomIndex = updateItem.CustomIndex; + } } - if (await _mediaCollectionRepository.Update(c)) + if (await dbContext.SaveChangesAsync() > 0) { // rebuild all playouts that use this collection - foreach (int playoutId in await _mediaCollectionRepository.PlayoutIdsUsingCollection( - request.CollectionId)) + foreach (int playoutId in await _mediaCollectionRepository + .PlayoutIdsUsingCollection(request.CollectionId)) { await _channel.WriteAsync(new BuildPlayout(playoutId, true)); } @@ -55,12 +68,17 @@ namespace ErsatzTV.Application.MediaCollections.Commands return Unit.Default; } - private Task> Validate(UpdateCollectionCustomOrder request) => - CollectionMustExist(request); + private static Task> Validate( + TvContext dbContext, + UpdateCollectionCustomOrder request) => + CollectionMustExist(dbContext, request); - private Task> CollectionMustExist( + private static Task> CollectionMustExist( + TvContext dbContext, UpdateCollectionCustomOrder request) => - _mediaCollectionRepository.Get(request.CollectionId) - .Map(v => v.ToValidation("Collection does not exist.")); + dbContext.Collections + .Include(c => c.CollectionItems) + .SelectOneAsync(c => c.Id, c => c.Id == request.CollectionId) + .Map(o => o.ToValidation("Collection does not exist.")); } } diff --git a/ErsatzTV.Application/MediaCollections/Commands/UpdateCollectionHandler.cs b/ErsatzTV.Application/MediaCollections/Commands/UpdateCollectionHandler.cs index d006ee94a..2d7847d05 100644 --- a/ErsatzTV.Application/MediaCollections/Commands/UpdateCollectionHandler.cs +++ b/ErsatzTV.Application/MediaCollections/Commands/UpdateCollectionHandler.cs @@ -5,36 +5,47 @@ using ErsatzTV.Application.Playouts.Commands; using ErsatzTV.Core; using ErsatzTV.Core.Domain; using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; +using Microsoft.EntityFrameworkCore; namespace ErsatzTV.Application.MediaCollections.Commands { public class UpdateCollectionHandler : MediatR.IRequestHandler> { private readonly ChannelWriter _channel; + private readonly IDbContextFactory _dbContextFactory; private readonly IMediaCollectionRepository _mediaCollectionRepository; public UpdateCollectionHandler( + IDbContextFactory dbContextFactory, IMediaCollectionRepository mediaCollectionRepository, ChannelWriter channel) { + _dbContextFactory = dbContextFactory; _mediaCollectionRepository = mediaCollectionRepository; _channel = channel; } - public Task> Handle( + public async Task> Handle( UpdateCollection request, - CancellationToken cancellationToken) => - Validate(request) - .MapT(c => ApplyUpdateRequest(c, request)) - .Bind(v => v.ToEitherAsync()); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + Validation validation = await Validate(dbContext, request); + return await validation.Apply(c => ApplyUpdateRequest(dbContext, c, request)); + } - private async Task ApplyUpdateRequest(Collection c, UpdateCollection request) + private async Task ApplyUpdateRequest(TvContext dbContext, Collection c, UpdateCollection request) { c.Name = request.Name; - await request.UseCustomPlaybackOrder.IfSomeAsync( - useCustomPlaybackOrder => c.UseCustomPlaybackOrder = useCustomPlaybackOrder); - if (await _mediaCollectionRepository.Update(c) && request.UseCustomPlaybackOrder.IsSome) + foreach (bool useCustomPlaybackOrder in request.UseCustomPlaybackOrder) + { + c.UseCustomPlaybackOrder = useCustomPlaybackOrder; + } + + if (await dbContext.SaveChangesAsync() > 0 && request.UseCustomPlaybackOrder.IsSome) { // rebuild all playouts that use this collection foreach (int playoutId in await _mediaCollectionRepository.PlayoutIdsUsingCollection( @@ -47,17 +58,20 @@ namespace ErsatzTV.Application.MediaCollections.Commands return Unit.Default; } - private async Task> - Validate(UpdateCollection request) => - (await CollectionMustExist(request), ValidateName(request)) + private static async Task> Validate( + TvContext dbContext, + UpdateCollection request) => + (await CollectionMustExist(dbContext, request), ValidateName(request)) .Apply((collectionToUpdate, _) => collectionToUpdate); - private Task> CollectionMustExist( + private static Task> CollectionMustExist( + TvContext dbContext, UpdateCollection updateCollection) => - _mediaCollectionRepository.Get(updateCollection.CollectionId) - .Map(v => v.ToValidation("Collection does not exist.")); + dbContext.Collections + .SelectOneAsync(c => c.Id, c => c.Id == updateCollection.CollectionId) + .Map(o => o.ToValidation("Collection does not exist.")); - private Validation ValidateName(UpdateCollection updateSimpleMediaCollection) => + private static Validation ValidateName(UpdateCollection updateSimpleMediaCollection) => updateSimpleMediaCollection.NotEmpty(c => c.Name) .Bind(_ => updateSimpleMediaCollection.NotLongerThan(50)(c => c.Name)); } diff --git a/ErsatzTV.Application/MediaCollections/Queries/GetAllCollectionsHandler.cs b/ErsatzTV.Application/MediaCollections/Queries/GetAllCollectionsHandler.cs index 0efde96ee..44b4b4f2d 100644 --- a/ErsatzTV.Application/MediaCollections/Queries/GetAllCollectionsHandler.cs +++ b/ErsatzTV.Application/MediaCollections/Queries/GetAllCollectionsHandler.cs @@ -2,23 +2,29 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; using LanguageExt; using MediatR; +using Microsoft.EntityFrameworkCore; using static ErsatzTV.Application.MediaCollections.Mapper; namespace ErsatzTV.Application.MediaCollections.Queries { public class GetAllCollectionsHandler : IRequestHandler> { - private readonly IMediaCollectionRepository _mediaCollectionRepository; + private readonly IDbContextFactory _dbContextFactory; - public GetAllCollectionsHandler(IMediaCollectionRepository mediaCollectionRepository) => - _mediaCollectionRepository = mediaCollectionRepository; + public GetAllCollectionsHandler(IDbContextFactory dbContextFactory) => + _dbContextFactory = dbContextFactory; - public Task> Handle( + public async Task> Handle( GetAllCollections request, - CancellationToken cancellationToken) => - _mediaCollectionRepository.GetAll().Map(list => list.Map(ProjectToViewModel).ToList()); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + return await dbContext.Collections + .ToListAsync(cancellationToken) + .Map(list => list.Map(ProjectToViewModel).ToList()); + } } } diff --git a/ErsatzTV.Application/MediaCollections/Queries/GetCollectionByIdHandler.cs b/ErsatzTV.Application/MediaCollections/Queries/GetCollectionByIdHandler.cs index e6bbb55b0..0f648728e 100644 --- a/ErsatzTV.Application/MediaCollections/Queries/GetCollectionByIdHandler.cs +++ b/ErsatzTV.Application/MediaCollections/Queries/GetCollectionByIdHandler.cs @@ -1,25 +1,30 @@ using System.Threading; using System.Threading.Tasks; -using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; using MediatR; +using Microsoft.EntityFrameworkCore; using static ErsatzTV.Application.MediaCollections.Mapper; namespace ErsatzTV.Application.MediaCollections.Queries { - public class - GetCollectionByIdHandler : IRequestHandler> + public class GetCollectionByIdHandler : + IRequestHandler> { - private readonly IMediaCollectionRepository _mediaCollectionRepository; + private readonly IDbContextFactory _dbContextFactory; - public GetCollectionByIdHandler(IMediaCollectionRepository mediaCollectionRepository) => - _mediaCollectionRepository = mediaCollectionRepository; + public GetCollectionByIdHandler(IDbContextFactory dbContextFactory) => + _dbContextFactory = dbContextFactory; - public Task> Handle( + public async Task> Handle( GetCollectionById request, - CancellationToken cancellationToken) => - _mediaCollectionRepository.Get(request.Id) + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + return await dbContext.Collections + .SelectOneAsync(c => c.Id, c => c.Id == request.Id) .MapT(ProjectToViewModel); + } } } diff --git a/ErsatzTV.Application/MediaCollections/Queries/GetCollectionItems.cs b/ErsatzTV.Application/MediaCollections/Queries/GetCollectionItems.cs deleted file mode 100644 index 35318b83d..000000000 --- a/ErsatzTV.Application/MediaCollections/Queries/GetCollectionItems.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Collections.Generic; -using ErsatzTV.Application.MediaItems; -using LanguageExt; -using MediatR; - -namespace ErsatzTV.Application.MediaCollections.Queries -{ - public record GetCollectionItems(int Id) : IRequest>>; -} diff --git a/ErsatzTV.Application/MediaCollections/Queries/GetCollectionItemsHandler.cs b/ErsatzTV.Application/MediaCollections/Queries/GetCollectionItemsHandler.cs deleted file mode 100644 index 11740f0cc..000000000 --- a/ErsatzTV.Application/MediaCollections/Queries/GetCollectionItemsHandler.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using ErsatzTV.Application.MediaItems; -using ErsatzTV.Core.Interfaces.Repositories; -using LanguageExt; -using MediatR; -using static ErsatzTV.Application.MediaItems.Mapper; - -namespace ErsatzTV.Application.MediaCollections.Queries -{ - public class GetCollectionItemsHandler : IRequestHandler>> - { - private readonly IMediaCollectionRepository _mediaCollectionRepository; - - public GetCollectionItemsHandler(IMediaCollectionRepository mediaCollectionRepository) => - _mediaCollectionRepository = mediaCollectionRepository; - - public Task>> Handle( - GetCollectionItems request, - CancellationToken cancellationToken) => - _mediaCollectionRepository.GetItems(request.Id) - .MapT(mediaItems => mediaItems.Map(ProjectToViewModel)); - } -} diff --git a/ErsatzTV.Application/MediaCollections/Queries/GetPagedCollectionsHandler.cs b/ErsatzTV.Application/MediaCollections/Queries/GetPagedCollectionsHandler.cs index 5433232a8..bf7b99b7b 100644 --- a/ErsatzTV.Application/MediaCollections/Queries/GetPagedCollectionsHandler.cs +++ b/ErsatzTV.Application/MediaCollections/Queries/GetPagedCollectionsHandler.cs @@ -1,29 +1,42 @@ using System.Collections.Generic; +using System.Data; using System.Linq; using System.Threading; using System.Threading.Tasks; -using ErsatzTV.Core.Interfaces.Repositories; +using Dapper; +using ErsatzTV.Infrastructure.Data; using LanguageExt; using MediatR; +using Microsoft.EntityFrameworkCore; using static ErsatzTV.Application.MediaCollections.Mapper; namespace ErsatzTV.Application.MediaCollections.Queries { public class GetPagedCollectionsHandler : IRequestHandler { - private readonly IMediaCollectionRepository _mediaCollectionRepository; + private readonly IDbConnection _dbConnection; + private readonly IDbContextFactory _dbContextFactory; - public GetPagedCollectionsHandler(IMediaCollectionRepository mediaCollectionRepository) => - _mediaCollectionRepository = mediaCollectionRepository; + public GetPagedCollectionsHandler(IDbContextFactory dbContextFactory, IDbConnection dbConnection) + { + _dbContextFactory = dbContextFactory; + _dbConnection = dbConnection; + } public async Task Handle( GetPagedCollections request, CancellationToken cancellationToken) { - int count = await _mediaCollectionRepository.CountAllCollections(); + int count = await _dbConnection.QuerySingleAsync(@"SELECT COUNT (*) FROM Collection"); - List page = await _mediaCollectionRepository - .GetPagedCollections(request.PageNum, request.PageSize) + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + List page = await dbContext.Collections.FromSqlRaw( + @"SELECT * FROM Collection + ORDER BY Name + LIMIT {0} OFFSET {1}", + request.PageSize, + request.PageNum * request.PageSize) + .ToListAsync(cancellationToken) .Map(list => list.Map(ProjectToViewModel).ToList()); return new PagedMediaCollectionsViewModel(count, page); diff --git a/ErsatzTV.Application/MediaItems/Mapper.cs b/ErsatzTV.Application/MediaItems/Mapper.cs index 793378a73..364631feb 100644 --- a/ErsatzTV.Application/MediaItems/Mapper.cs +++ b/ErsatzTV.Application/MediaItems/Mapper.cs @@ -4,9 +4,6 @@ namespace ErsatzTV.Application.MediaItems { internal static class Mapper { - internal static MediaItemViewModel ProjectToViewModel(MediaItem mediaItem) => - new(mediaItem.Id, mediaItem.LibraryPathId); - internal static NamedMediaItemViewModel ProjectToViewModel(Show show) => new(show.Id, show.ShowMetadata.HeadOrNone().Map(sm => $"{sm?.Title} ({sm?.Year})").IfNone("???")); diff --git a/ErsatzTV.Application/MediaItems/MediaItemSearchResultViewModel.cs b/ErsatzTV.Application/MediaItems/MediaItemSearchResultViewModel.cs deleted file mode 100644 index 6ff72c912..000000000 --- a/ErsatzTV.Application/MediaItems/MediaItemSearchResultViewModel.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace ErsatzTV.Application.MediaItems -{ - public record MediaItemSearchResultViewModel( - int Id, - string Source, - string MediaType, - string Title, - string Duration); -} diff --git a/ErsatzTV.Application/MediaItems/MediaItemViewModel.cs b/ErsatzTV.Application/MediaItems/MediaItemViewModel.cs deleted file mode 100644 index b2cc42d23..000000000 --- a/ErsatzTV.Application/MediaItems/MediaItemViewModel.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace ErsatzTV.Application.MediaItems -{ - public record MediaItemViewModel(int Id, int LibraryPathId); -} diff --git a/ErsatzTV.Application/MediaItems/Queries/GetAllMediaItems.cs b/ErsatzTV.Application/MediaItems/Queries/GetAllMediaItems.cs deleted file mode 100644 index cf06145aa..000000000 --- a/ErsatzTV.Application/MediaItems/Queries/GetAllMediaItems.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System.Collections.Generic; -using MediatR; - -namespace ErsatzTV.Application.MediaItems.Queries -{ - public record GetAllMediaItems : IRequest>; -} diff --git a/ErsatzTV.Application/MediaItems/Queries/GetAllMediaItemsHandler.cs b/ErsatzTV.Application/MediaItems/Queries/GetAllMediaItemsHandler.cs deleted file mode 100644 index e646db23d..000000000 --- a/ErsatzTV.Application/MediaItems/Queries/GetAllMediaItemsHandler.cs +++ /dev/null @@ -1,24 +0,0 @@ -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.MediaItems.Mapper; - -namespace ErsatzTV.Application.MediaItems.Queries -{ - public class GetAllMediaItemsHandler : IRequestHandler> - { - private readonly IMediaItemRepository _mediaItemRepository; - - public GetAllMediaItemsHandler(IMediaItemRepository mediaItemRepository) => - _mediaItemRepository = mediaItemRepository; - - public Task> Handle( - GetAllMediaItems request, - CancellationToken cancellationToken) => - _mediaItemRepository.GetAll().Map(list => list.Map(ProjectToViewModel).ToList()); - } -} diff --git a/ErsatzTV.Application/MediaItems/Queries/GetMediaItemById.cs b/ErsatzTV.Application/MediaItems/Queries/GetMediaItemById.cs deleted file mode 100644 index 8586d72f5..000000000 --- a/ErsatzTV.Application/MediaItems/Queries/GetMediaItemById.cs +++ /dev/null @@ -1,7 +0,0 @@ -using LanguageExt; -using MediatR; - -namespace ErsatzTV.Application.MediaItems.Queries -{ - public record GetMediaItemById(int Id) : IRequest>; -} diff --git a/ErsatzTV.Application/MediaItems/Queries/GetMediaItemByIdHandler.cs b/ErsatzTV.Application/MediaItems/Queries/GetMediaItemByIdHandler.cs deleted file mode 100644 index 279159075..000000000 --- a/ErsatzTV.Application/MediaItems/Queries/GetMediaItemByIdHandler.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; -using ErsatzTV.Core.Interfaces.Repositories; -using LanguageExt; -using MediatR; -using static ErsatzTV.Application.MediaItems.Mapper; - -namespace ErsatzTV.Application.MediaItems.Queries -{ - public class GetMediaItemByIdHandler : IRequestHandler> - { - private readonly IMediaItemRepository _mediaItemRepository; - - public GetMediaItemByIdHandler(IMediaItemRepository mediaItemRepository) => - _mediaItemRepository = mediaItemRepository; - - public Task> Handle( - GetMediaItemById request, - CancellationToken cancellationToken) => - _mediaItemRepository.Get(request.Id) - .MapT(ProjectToViewModel); - } -} diff --git a/ErsatzTV.Application/MediaSources/Mapper.cs b/ErsatzTV.Application/MediaSources/Mapper.cs deleted file mode 100644 index e586c663b..000000000 --- a/ErsatzTV.Application/MediaSources/Mapper.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using ErsatzTV.Core.Domain; - -namespace ErsatzTV.Application.MediaSources -{ - internal static class Mapper - { - internal static MediaSourceViewModel ProjectToViewModel(MediaSource mediaSource) => - mediaSource switch - { - LocalMediaSource lms => new LocalMediaSourceViewModel(lms.Id), - PlexMediaSource pms => Plex.Mapper.ProjectToViewModel(pms), - _ => throw new NotSupportedException($"Unsupported media source {mediaSource.GetType().Name}") - }; - } -} diff --git a/ErsatzTV.Application/MediaSources/Queries/CountMediaItemsById.cs b/ErsatzTV.Application/MediaSources/Queries/CountMediaItemsById.cs deleted file mode 100644 index b2432ca47..000000000 --- a/ErsatzTV.Application/MediaSources/Queries/CountMediaItemsById.cs +++ /dev/null @@ -1,6 +0,0 @@ -using MediatR; - -namespace ErsatzTV.Application.MediaSources.Queries -{ - public record CountMediaItemsById(int MediaSourceId) : IRequest; -} diff --git a/ErsatzTV.Application/MediaSources/Queries/CountMediaItemsByIdHandler.cs b/ErsatzTV.Application/MediaSources/Queries/CountMediaItemsByIdHandler.cs deleted file mode 100644 index 9b1c60e98..000000000 --- a/ErsatzTV.Application/MediaSources/Queries/CountMediaItemsByIdHandler.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; -using ErsatzTV.Core.Interfaces.Repositories; -using MediatR; - -namespace ErsatzTV.Application.MediaSources.Queries -{ - public class CountMediaItemsByIdHandler : IRequestHandler - { - private readonly IMediaSourceRepository _mediaSourceRepository; - - public CountMediaItemsByIdHandler(IMediaSourceRepository mediaSourceRepository) => - _mediaSourceRepository = mediaSourceRepository; - - public Task Handle(CountMediaItemsById request, CancellationToken cancellationToken) => - _mediaSourceRepository.CountMediaItems(request.MediaSourceId); - } -} diff --git a/ErsatzTV.Application/MediaSources/Queries/GetAllMediaSources.cs b/ErsatzTV.Application/MediaSources/Queries/GetAllMediaSources.cs deleted file mode 100644 index fbf68473c..000000000 --- a/ErsatzTV.Application/MediaSources/Queries/GetAllMediaSources.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System.Collections.Generic; -using MediatR; - -namespace ErsatzTV.Application.MediaSources.Queries -{ - public record GetAllMediaSources : IRequest>; -} diff --git a/ErsatzTV.Application/MediaSources/Queries/GetAllMediaSourcesHandler.cs b/ErsatzTV.Application/MediaSources/Queries/GetAllMediaSourcesHandler.cs deleted file mode 100644 index 27cb1e255..000000000 --- a/ErsatzTV.Application/MediaSources/Queries/GetAllMediaSourcesHandler.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using ErsatzTV.Core.Interfaces.Repositories; -using MediatR; -using static ErsatzTV.Application.MediaSources.Mapper; - -namespace ErsatzTV.Application.MediaSources.Queries -{ - public class GetAllMediaSourcesHandler : IRequestHandler> - { - private readonly IMediaSourceRepository _mediaSourceRepository; - - public GetAllMediaSourcesHandler(IMediaSourceRepository mediaSourceRepository) => - _mediaSourceRepository = mediaSourceRepository; - - public async Task> Handle( - GetAllMediaSources request, - CancellationToken cancellationToken) => - (await _mediaSourceRepository.GetAll()).Map(ProjectToViewModel).ToList(); - } -} diff --git a/ErsatzTV.Application/MediaSources/Queries/GetMediaSourceById.cs b/ErsatzTV.Application/MediaSources/Queries/GetMediaSourceById.cs deleted file mode 100644 index 2e96d3d33..000000000 --- a/ErsatzTV.Application/MediaSources/Queries/GetMediaSourceById.cs +++ /dev/null @@ -1,7 +0,0 @@ -using LanguageExt; -using MediatR; - -namespace ErsatzTV.Application.MediaSources.Queries -{ - public record GetMediaSourceById(int Id) : IRequest>; -} diff --git a/ErsatzTV.Application/MediaSources/Queries/GetMediaSourceByIdHandler.cs b/ErsatzTV.Application/MediaSources/Queries/GetMediaSourceByIdHandler.cs deleted file mode 100644 index 97374a020..000000000 --- a/ErsatzTV.Application/MediaSources/Queries/GetMediaSourceByIdHandler.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; -using ErsatzTV.Core.Interfaces.Repositories; -using LanguageExt; -using MediatR; -using static ErsatzTV.Application.MediaSources.Mapper; - -namespace ErsatzTV.Application.MediaSources.Queries -{ - public class GetMediaSourceByIdHandler : IRequestHandler> - { - private readonly IMediaSourceRepository _mediaSourceRepository; - - public GetMediaSourceByIdHandler(IMediaSourceRepository mediaSourceRepository) => - _mediaSourceRepository = mediaSourceRepository; - - public Task> Handle( - GetMediaSourceById request, - CancellationToken cancellationToken) => - _mediaSourceRepository.Get(request.Id) - .MapT(ProjectToViewModel); - } -} diff --git a/ErsatzTV.Application/Playouts/Commands/BuildPlayoutHandler.cs b/ErsatzTV.Application/Playouts/Commands/BuildPlayoutHandler.cs index 72d3a9609..3b37bb098 100644 --- a/ErsatzTV.Application/Playouts/Commands/BuildPlayoutHandler.cs +++ b/ErsatzTV.Application/Playouts/Commands/BuildPlayoutHandler.cs @@ -2,41 +2,57 @@ using System.Threading.Tasks; using ErsatzTV.Core; using ErsatzTV.Core.Domain; -using ErsatzTV.Core.Interfaces.Repositories; using ErsatzTV.Core.Interfaces.Scheduling; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; -using static LanguageExt.Prelude; +using Microsoft.EntityFrameworkCore; namespace ErsatzTV.Application.Playouts.Commands { public class BuildPlayoutHandler : MediatR.IRequestHandler> { + private readonly IDbContextFactory _dbContextFactory; private readonly IPlayoutBuilder _playoutBuilder; - private readonly IPlayoutRepository _playoutRepository; - public BuildPlayoutHandler(IPlayoutRepository playoutRepository, IPlayoutBuilder playoutBuilder) + public BuildPlayoutHandler(IDbContextFactory dbContextFactory, IPlayoutBuilder playoutBuilder) { - _playoutRepository = playoutRepository; + _dbContextFactory = dbContextFactory; _playoutBuilder = playoutBuilder; } - public Task> Handle(BuildPlayout request, CancellationToken cancellationToken) => - Validate(request) - .Map(v => v.ToEither()) - .BindT(playout => ApplyUpdateRequest(request, playout)); + public async Task> Handle(BuildPlayout request, CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + Validation validation = await Validate(dbContext, request); + return await validation.Apply(playout => ApplyUpdateRequest(dbContext, request, playout)); + } - private async Task> ApplyUpdateRequest(BuildPlayout request, Playout playout) + private async Task ApplyUpdateRequest(TvContext dbContext, BuildPlayout request, Playout playout) { - Playout result = await _playoutBuilder.BuildPlayoutItems(playout, request.Rebuild); - await _playoutRepository.Update(result); - return unit; + await _playoutBuilder.BuildPlayoutItems(playout, request.Rebuild); + await dbContext.SaveChangesAsync(); + return Unit.Default; } - private Task> Validate(BuildPlayout request) => - PlayoutMustExist(request); + private static Task> Validate(TvContext dbContext, BuildPlayout request) => + PlayoutMustExist(dbContext, request); - private async Task> PlayoutMustExist(BuildPlayout buildPlayout) => - (await _playoutRepository.GetFull(buildPlayout.PlayoutId)) - .ToValidation("Playout does not exist."); + private static Task> PlayoutMustExist( + TvContext dbContext, + BuildPlayout buildPlayout) => + dbContext.Playouts + .Include(p => p.Channel) + .Include(p => p.Items) + .Include(p => p.ProgramScheduleAnchors) + .ThenInclude(a => a.MediaItem) + .Include(p => p.ProgramSchedule) + .ThenInclude(ps => ps.Items) + .ThenInclude(psi => psi.Collection) + .Include(p => p.ProgramSchedule) + .ThenInclude(ps => ps.Items) + .ThenInclude(psi => psi.MediaItem) + .SelectOneAsync(p => p.Id, p => p.Id == buildPlayout.PlayoutId) + .Map(o => o.ToValidation("Playout does not exist.")); } } diff --git a/ErsatzTV.Application/Playouts/Commands/CreatePlayout.cs b/ErsatzTV.Application/Playouts/Commands/CreatePlayout.cs index 6c5ef28d9..68a47d502 100644 --- a/ErsatzTV.Application/Playouts/Commands/CreatePlayout.cs +++ b/ErsatzTV.Application/Playouts/Commands/CreatePlayout.cs @@ -8,5 +8,5 @@ namespace ErsatzTV.Application.Playouts.Commands public record CreatePlayout( int ChannelId, int ProgramScheduleId, - ProgramSchedulePlayoutType ProgramSchedulePlayoutType) : IRequest>; + ProgramSchedulePlayoutType ProgramSchedulePlayoutType) : IRequest>; } diff --git a/ErsatzTV.Application/Playouts/Commands/CreatePlayoutHandler.cs b/ErsatzTV.Application/Playouts/Commands/CreatePlayoutHandler.cs index d3d6efc47..48c6a3e5b 100644 --- a/ErsatzTV.Application/Playouts/Commands/CreatePlayoutHandler.cs +++ b/ErsatzTV.Application/Playouts/Commands/CreatePlayoutHandler.cs @@ -4,51 +4,50 @@ using System.Threading.Channels; using System.Threading.Tasks; using ErsatzTV.Core; using ErsatzTV.Core.Domain; -using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; using MediatR; -using static ErsatzTV.Application.Playouts.Mapper; +using Microsoft.EntityFrameworkCore; using static LanguageExt.Prelude; using Channel = ErsatzTV.Core.Domain.Channel; namespace ErsatzTV.Application.Playouts.Commands { - public class - CreatePlayoutHandler : IRequestHandler> + public class CreatePlayoutHandler : IRequestHandler> { private readonly ChannelWriter _channel; - private readonly IChannelRepository _channelRepository; - private readonly IPlayoutRepository _playoutRepository; - private readonly IProgramScheduleRepository _programScheduleRepository; + private readonly IDbContextFactory _dbContextFactory; public CreatePlayoutHandler( - IPlayoutRepository playoutRepository, - IChannelRepository channelRepository, - IProgramScheduleRepository programScheduleRepository, - ChannelWriter channel) + ChannelWriter channel, + IDbContextFactory dbContextFactory) { - _playoutRepository = playoutRepository; - _channelRepository = channelRepository; - _programScheduleRepository = programScheduleRepository; _channel = channel; + _dbContextFactory = dbContextFactory; } - public Task> Handle( + public async Task> Handle( CreatePlayout request, - CancellationToken cancellationToken) => - Validate(request) - .MapT(PersistPlayout) - .Bind(v => v.ToEitherAsync()); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + + Validation validation = await Validate(dbContext, request); + return await validation.Apply(playout => PersistPlayout(dbContext, playout)); + } - private async Task PersistPlayout(Playout c) + private async Task PersistPlayout(TvContext dbContext, Playout playout) { - PlayoutViewModel result = await _playoutRepository.Add(c).Map(ProjectToViewModel); - await _channel.WriteAsync(new BuildPlayout(result.Id)); - return result; + await dbContext.Playouts.AddAsync(playout); + await dbContext.SaveChangesAsync(); + await _channel.WriteAsync(new BuildPlayout(playout.Id)); + return new CreatePlayoutResponse(playout.Id); } - private async Task> Validate(CreatePlayout request) => - (await ValidateChannel(request), await ProgramScheduleMustExist(request), ValidatePlayoutType(request)) + private async Task> Validate(TvContext dbContext, CreatePlayout request) => + (await ValidateChannel(dbContext, request), await ValidateProgramSchedule(dbContext, request), + ValidatePlayoutType(request)) .Apply( (channel, programSchedule, playoutType) => new Playout { @@ -57,31 +56,38 @@ namespace ErsatzTV.Application.Playouts.Commands ProgramSchedulePlayoutType = playoutType }); - private Task> ValidateChannel(CreatePlayout createPlayout) => - ChannelMustExist(createPlayout).BindT(ChannelMustNotHavePlayouts); - - private async Task> ChannelMustExist(CreatePlayout createPlayout) => - (await _channelRepository.Get(createPlayout.ChannelId)) - .ToValidation("Channel does not exist."); + private static Task> ValidateChannel( + TvContext dbContext, + CreatePlayout createPlayout) => + dbContext.Channels + .Include(c => c.Playouts) + .SelectOneAsync(c => c.Id, c => c.Id == createPlayout.ChannelId) + .Map(o => o.ToValidation("Channel does not exist")) + .BindT(ChannelMustNotHavePlayouts); - private async Task> ChannelMustNotHavePlayouts(Channel channel) => - Optional(await _channelRepository.CountPlayouts(channel.Id)) + private static Validation ChannelMustNotHavePlayouts(Channel channel) => + Optional(channel.Playouts.Count) .Filter(count => count == 0) .Map(_ => channel) - .ToValidation("Channel already has one playout."); + .ToValidation("Channel already has one playout"); - private async Task> ProgramScheduleMustExist( + private static Task> ValidateProgramSchedule( + TvContext dbContext, CreatePlayout createPlayout) => - (await _programScheduleRepository.GetWithPlayouts(createPlayout.ProgramScheduleId)) - .ToValidation("ProgramSchedule does not exist.") - .Bind(ProgramScheduleMustHaveItems); + dbContext.ProgramSchedules + .Include(ps => ps.Items) + .SelectOneAsync(ps => ps.Id, ps => ps.Id == createPlayout.ProgramScheduleId) + .Map(o => o.ToValidation("Program schedule does not exist")) + .BindT(ProgramScheduleMustHaveItems); - private Validation ProgramScheduleMustHaveItems(ProgramSchedule programSchedule) => + private static Validation ProgramScheduleMustHaveItems( + ProgramSchedule programSchedule) => Optional(programSchedule) .Filter(ps => ps.Items.Any()) .ToValidation("Program schedule must have items"); - private Validation ValidatePlayoutType(CreatePlayout createPlayout) => + private static Validation ValidatePlayoutType( + CreatePlayout createPlayout) => Optional(createPlayout.ProgramSchedulePlayoutType) .Filter(playoutType => playoutType != ProgramSchedulePlayoutType.None) .ToValidation("[ProgramSchedulePlayoutType] must not be None"); diff --git a/ErsatzTV.Application/Playouts/Commands/CreatePlayoutResponse.cs b/ErsatzTV.Application/Playouts/Commands/CreatePlayoutResponse.cs new file mode 100644 index 000000000..c5d266f89 --- /dev/null +++ b/ErsatzTV.Application/Playouts/Commands/CreatePlayoutResponse.cs @@ -0,0 +1,4 @@ +namespace ErsatzTV.Application.Playouts.Commands +{ + public record CreatePlayoutResponse(int PlayoutId); +} diff --git a/ErsatzTV.Application/Playouts/Commands/DeletePlayout.cs b/ErsatzTV.Application/Playouts/Commands/DeletePlayout.cs index 8469ece7b..ddbb53384 100644 --- a/ErsatzTV.Application/Playouts/Commands/DeletePlayout.cs +++ b/ErsatzTV.Application/Playouts/Commands/DeletePlayout.cs @@ -1,9 +1,9 @@ -using System.Threading.Tasks; -using ErsatzTV.Core; +using ErsatzTV.Core; using LanguageExt; using MediatR; +using Unit = LanguageExt.Unit; namespace ErsatzTV.Application.Playouts.Commands { - public record DeletePlayout(int PlayoutId) : IRequest>; + public record DeletePlayout(int PlayoutId) : IRequest>; } diff --git a/ErsatzTV.Application/Playouts/Commands/DeletePlayoutHandler.cs b/ErsatzTV.Application/Playouts/Commands/DeletePlayoutHandler.cs index d9d3df9d5..9240ab05e 100644 --- a/ErsatzTV.Application/Playouts/Commands/DeletePlayoutHandler.cs +++ b/ErsatzTV.Application/Playouts/Commands/DeletePlayoutHandler.cs @@ -1,32 +1,42 @@ -using System.Threading; +using System.Linq; +using System.Threading; using System.Threading.Tasks; using ErsatzTV.Core; -using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Core.Domain; +using ErsatzTV.Infrastructure.Data; using LanguageExt; using MediatR; +using Microsoft.EntityFrameworkCore; +using Unit = LanguageExt.Unit; namespace ErsatzTV.Application.Playouts.Commands { - public class DeletePlayoutHandler : IRequestHandler> + public class DeletePlayoutHandler : IRequestHandler> { - private readonly IPlayoutRepository _playoutRepository; + private readonly IDbContextFactory _dbContextFactory; - public DeletePlayoutHandler(IPlayoutRepository playoutRepository) => - _playoutRepository = playoutRepository; + public DeletePlayoutHandler(IDbContextFactory dbContextFactory) => + _dbContextFactory = dbContextFactory; - public async Task> Handle( + public async Task> Handle( DeletePlayout request, - CancellationToken cancellationToken) => - (await PlayoutMustExist(request)) - .Map(DoDeletion) - .ToEither(); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); - private Task DoDeletion(int playoutId) => _playoutRepository.Delete(playoutId); + Option maybePlayout = await dbContext.Playouts + .OrderBy(p => p.Id) + .FirstOrDefaultAsync(p => p.Id == request.PlayoutId, cancellationToken); - private async Task> PlayoutMustExist( - DeletePlayout deletePlayout) => - (await _playoutRepository.Get(deletePlayout.PlayoutId)) - .ToValidation($"Playout {deletePlayout.PlayoutId} does not exist.") - .Map(c => c.Id); + foreach (Playout playout in maybePlayout) + { + dbContext.Playouts.Remove(playout); + await dbContext.SaveChangesAsync(cancellationToken); + } + + return maybePlayout + .Map(_ => Unit.Default) + .ToEither(BaseError.New($"Playout {request.PlayoutId} does not exist.")); + } } } diff --git a/ErsatzTV.Application/Playouts/Commands/UpdatePlayout.cs b/ErsatzTV.Application/Playouts/Commands/UpdatePlayout.cs deleted file mode 100644 index d4df2174e..000000000 --- a/ErsatzTV.Application/Playouts/Commands/UpdatePlayout.cs +++ /dev/null @@ -1,13 +0,0 @@ -using ErsatzTV.Core; -using ErsatzTV.Core.Domain; -using LanguageExt; -using MediatR; - -namespace ErsatzTV.Application.Playouts.Commands -{ - public record UpdatePlayout( - int PlayoutId, - int ChannelId, - int ProgramScheduleId, - ProgramSchedulePlayoutType ProgramSchedulePlayoutType) : IRequest>; -} diff --git a/ErsatzTV.Application/Playouts/Commands/UpdatePlayoutHandler.cs b/ErsatzTV.Application/Playouts/Commands/UpdatePlayoutHandler.cs deleted file mode 100644 index a5de30e20..000000000 --- a/ErsatzTV.Application/Playouts/Commands/UpdatePlayoutHandler.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System.Threading; -using System.Threading.Channels; -using System.Threading.Tasks; -using ErsatzTV.Core; -using ErsatzTV.Core.Domain; -using ErsatzTV.Core.Interfaces.Repositories; -using LanguageExt; -using MediatR; -using static LanguageExt.Prelude; -using static ErsatzTV.Application.Playouts.Mapper; -using Channel = ErsatzTV.Core.Domain.Channel; - -namespace ErsatzTV.Application.Playouts.Commands -{ - public class UpdatePlayoutHandler : IRequestHandler> - { - private readonly ChannelWriter _channel; - private readonly IChannelRepository _channelRepository; - private readonly IPlayoutRepository _playoutRepository; - private readonly IProgramScheduleRepository _programScheduleRepository; - - public UpdatePlayoutHandler( - IPlayoutRepository playoutRepository, - IChannelRepository channelRepository, - IProgramScheduleRepository programScheduleRepository, - ChannelWriter channel) - { - _playoutRepository = playoutRepository; - _channelRepository = channelRepository; - _programScheduleRepository = programScheduleRepository; - _channel = channel; - } - - public Task> Handle( - UpdatePlayout request, - CancellationToken cancellationToken) => - Validate(request) - .MapT(c => ApplyUpdateRequest(c, request)) - .Bind(v => v.ToEitherAsync()); - - private async Task ApplyUpdateRequest(Playout p, UpdatePlayout update) - { - p.ChannelId = update.ChannelId; - p.ProgramScheduleId = update.ProgramScheduleId; - p.ProgramSchedulePlayoutType = update.ProgramSchedulePlayoutType; - await _playoutRepository.Update(p); - await _channel.WriteAsync(new BuildPlayout(p.Id)); - return ProjectToViewModel(p); - } - - private async Task> Validate(UpdatePlayout request) => - (await PlayoutMustExist(request), await ChannelMustExist(request), await ProgramScheduleMustExist(request), - ValidatePlayoutType(request)) - .Apply( - (playoutToUpdate, _, _, _) => playoutToUpdate); - - private async Task> PlayoutMustExist(UpdatePlayout updatePlayout) => - (await _playoutRepository.Get(updatePlayout.PlayoutId)) - .ToValidation("Playout does not exist."); - - private async Task> ChannelMustExist(UpdatePlayout createPlayout) => - (await _channelRepository.Get(createPlayout.ChannelId)) - .ToValidation("Channel does not exist."); - - private async Task> - ProgramScheduleMustExist(UpdatePlayout createPlayout) => - (await _programScheduleRepository.Get(createPlayout.ProgramScheduleId)) - .ToValidation("ProgramSchedule does not exist."); - - private Validation ValidatePlayoutType(UpdatePlayout createPlayout) => - Optional(createPlayout.ProgramSchedulePlayoutType) - .Filter(playoutType => playoutType != ProgramSchedulePlayoutType.None) - .ToValidation("[ProgramSchedulePlayoutType] must not be None"); - } -} diff --git a/ErsatzTV.Application/Playouts/Mapper.cs b/ErsatzTV.Application/Playouts/Mapper.cs index d24316658..d819b28ec 100644 --- a/ErsatzTV.Application/Playouts/Mapper.cs +++ b/ErsatzTV.Application/Playouts/Mapper.cs @@ -6,25 +6,12 @@ namespace ErsatzTV.Application.Playouts { internal static class Mapper { - internal static PlayoutViewModel ProjectToViewModel(Playout playout) => - new( - playout.Id, - Project(playout.Channel), - Project(playout.ProgramSchedule), - playout.ProgramSchedulePlayoutType); - internal static PlayoutItemViewModel ProjectToViewModel(PlayoutItem playoutItem) => new( GetDisplayTitle(playoutItem.MediaItem), playoutItem.StartOffset, GetDisplayDuration(playoutItem.MediaItem)); - private static PlayoutChannelViewModel Project(Channel channel) => - new(channel.Id, channel.Number, channel.Name); - - private static PlayoutProgramScheduleViewModel Project(ProgramSchedule programSchedule) => - new(programSchedule.Id, programSchedule.Name); - private static string GetDisplayTitle(MediaItem mediaItem) { switch (mediaItem) diff --git a/ErsatzTV.Application/Playouts/PlayoutNameViewModel.cs b/ErsatzTV.Application/Playouts/PlayoutNameViewModel.cs new file mode 100644 index 000000000..d5d660077 --- /dev/null +++ b/ErsatzTV.Application/Playouts/PlayoutNameViewModel.cs @@ -0,0 +1,8 @@ +namespace ErsatzTV.Application.Playouts +{ + public record PlayoutNameViewModel( + int PlayoutId, + string ChannelName, + string ChannelNumber, + string ScheduleName); +} diff --git a/ErsatzTV.Application/Playouts/Queries/GetAllPlayouts.cs b/ErsatzTV.Application/Playouts/Queries/GetAllPlayouts.cs index 40c360608..ae258c66a 100644 --- a/ErsatzTV.Application/Playouts/Queries/GetAllPlayouts.cs +++ b/ErsatzTV.Application/Playouts/Queries/GetAllPlayouts.cs @@ -3,5 +3,5 @@ using MediatR; namespace ErsatzTV.Application.Playouts.Queries { - public record GetAllPlayouts : IRequest>; + public record GetAllPlayouts : IRequest>; } diff --git a/ErsatzTV.Application/Playouts/Queries/GetAllPlayoutsHandler.cs b/ErsatzTV.Application/Playouts/Queries/GetAllPlayoutsHandler.cs index 0761bbf5f..4ab9e433b 100644 --- a/ErsatzTV.Application/Playouts/Queries/GetAllPlayoutsHandler.cs +++ b/ErsatzTV.Application/Playouts/Queries/GetAllPlayoutsHandler.cs @@ -1,24 +1,28 @@ using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; -using ErsatzTV.Core.Interfaces.Repositories; -using LanguageExt; +using ErsatzTV.Infrastructure.Data; using MediatR; -using static ErsatzTV.Application.Playouts.Mapper; +using Microsoft.EntityFrameworkCore; namespace ErsatzTV.Application.Playouts.Queries { - public class GetAllPlayoutsHandler : IRequestHandler> + public class GetAllPlayoutsHandler : IRequestHandler> { - private readonly IPlayoutRepository _playoutRepository; + private readonly IDbContextFactory _dbContextFactory; - public GetAllPlayoutsHandler(IPlayoutRepository playoutRepository) => - _playoutRepository = playoutRepository; + public GetAllPlayoutsHandler(IDbContextFactory dbContextFactory) => + _dbContextFactory = dbContextFactory; - public Task> Handle( + public async Task> Handle( GetAllPlayouts request, - CancellationToken cancellationToken) => - _playoutRepository.GetAll().Map(list => list.Map(ProjectToViewModel).ToList()); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + return await dbContext.Playouts + .Filter(p => p.Channel != null && p.ProgramSchedule != null) + .Map(p => new PlayoutNameViewModel(p.Id, p.Channel.Name, p.Channel.Number, p.ProgramSchedule.Name)) + .ToListAsync(cancellationToken); + } } } diff --git a/ErsatzTV.Application/Playouts/Queries/GetPlayoutById.cs b/ErsatzTV.Application/Playouts/Queries/GetPlayoutById.cs deleted file mode 100644 index f4b9bcf6f..000000000 --- a/ErsatzTV.Application/Playouts/Queries/GetPlayoutById.cs +++ /dev/null @@ -1,7 +0,0 @@ -using LanguageExt; -using MediatR; - -namespace ErsatzTV.Application.Playouts.Queries -{ - public record GetPlayoutById(int Id) : IRequest>; -} diff --git a/ErsatzTV.Application/Playouts/Queries/GetPlayoutByIdHandler.cs b/ErsatzTV.Application/Playouts/Queries/GetPlayoutByIdHandler.cs deleted file mode 100644 index 736f9d47d..000000000 --- a/ErsatzTV.Application/Playouts/Queries/GetPlayoutByIdHandler.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; -using ErsatzTV.Core.Interfaces.Repositories; -using LanguageExt; -using MediatR; -using static ErsatzTV.Application.Playouts.Mapper; - -namespace ErsatzTV.Application.Playouts.Queries -{ - public class - GetPlayoutByIdHandler : IRequestHandler> - { - private readonly IPlayoutRepository _playoutRepository; - - public GetPlayoutByIdHandler(IPlayoutRepository playoutRepository) => - _playoutRepository = playoutRepository; - - public Task> Handle( - GetPlayoutById request, - CancellationToken cancellationToken) => - _playoutRepository.Get(request.Id) - .MapT(ProjectToViewModel); - } -} diff --git a/ErsatzTV.Application/Playouts/Queries/GetPlayoutItemsByIdHandler.cs b/ErsatzTV.Application/Playouts/Queries/GetPlayoutItemsByIdHandler.cs index 60ec68cc5..e3c629624 100644 --- a/ErsatzTV.Application/Playouts/Queries/GetPlayoutItemsByIdHandler.cs +++ b/ErsatzTV.Application/Playouts/Queries/GetPlayoutItemsByIdHandler.cs @@ -2,24 +2,55 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Core.Domain; +using ErsatzTV.Infrastructure.Data; using LanguageExt; using MediatR; +using Microsoft.EntityFrameworkCore; using static ErsatzTV.Application.Playouts.Mapper; namespace ErsatzTV.Application.Playouts.Queries { public class GetPlayoutItemsByIdHandler : IRequestHandler> { - private readonly IPlayoutRepository _playoutRepository; + private readonly IDbContextFactory _dbContextFactory; - public GetPlayoutItemsByIdHandler(IPlayoutRepository playoutRepository) => - _playoutRepository = playoutRepository; + public GetPlayoutItemsByIdHandler(IDbContextFactory dbContextFactory) => + _dbContextFactory = dbContextFactory; - public Task> Handle( + public async Task> Handle( GetPlayoutItemsById request, - CancellationToken cancellationToken) => - _playoutRepository.GetPlayoutItems(request.PlayoutId) + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + return await dbContext.PlayoutItems + .Include(i => i.MediaItem) + .ThenInclude(mi => (mi as Movie).MovieMetadata) + .ThenInclude(mm => mm.Artwork) + .Include(i => i.MediaItem) + .ThenInclude(mi => (mi as Movie).MediaVersions) + .Include(i => i.MediaItem) + .ThenInclude(mi => (mi as MusicVideo).MusicVideoMetadata) + .ThenInclude(mm => mm.Artwork) + .Include(i => i.MediaItem) + .ThenInclude(mi => (mi as MusicVideo).MediaVersions) + .Include(i => i.MediaItem) + .ThenInclude(mi => (mi as MusicVideo).Artist) + .ThenInclude(mm => mm.ArtistMetadata) + .Include(i => i.MediaItem) + .ThenInclude(mi => (mi as Episode).EpisodeMetadata) + .ThenInclude(em => em.Artwork) + .Include(i => i.MediaItem) + .ThenInclude(mi => (mi as Episode).MediaVersions) + .Include(i => i.MediaItem) + .ThenInclude(mi => (mi as Episode).Season) + .ThenInclude(s => s.SeasonMetadata) + .Include(i => i.MediaItem) + .ThenInclude(mi => (mi as Episode).Season.Show) + .ThenInclude(s => s.ShowMetadata) + .Filter(i => i.PlayoutId == request.PlayoutId) + .ToListAsync(cancellationToken) .Map(list => list.Map(ProjectToViewModel).ToList()); + } } } diff --git a/ErsatzTV.Application/ProgramSchedules/Commands/AddProgramScheduleItemHandler.cs b/ErsatzTV.Application/ProgramSchedules/Commands/AddProgramScheduleItemHandler.cs index 787e6c123..7a9866089 100644 --- a/ErsatzTV.Application/ProgramSchedules/Commands/AddProgramScheduleItemHandler.cs +++ b/ErsatzTV.Application/ProgramSchedules/Commands/AddProgramScheduleItemHandler.cs @@ -5,36 +5,39 @@ using System.Threading.Tasks; using ErsatzTV.Application.Playouts.Commands; using ErsatzTV.Core; using ErsatzTV.Core.Domain; -using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; using LanguageExt; using MediatR; +using Microsoft.EntityFrameworkCore; using static ErsatzTV.Application.ProgramSchedules.Mapper; namespace ErsatzTV.Application.ProgramSchedules.Commands { - public class AddProgramScheduleItemHandler : ProgramScheduleItemCommandBase, IRequestHandler> + public class AddProgramScheduleItemHandler : ProgramScheduleItemCommandBase, + IRequestHandler> { private readonly ChannelWriter _channel; - private readonly IProgramScheduleRepository _programScheduleRepository; + private readonly IDbContextFactory _dbContextFactory; public AddProgramScheduleItemHandler( - IProgramScheduleRepository programScheduleRepository, + IDbContextFactory dbContextFactory, ChannelWriter channel) - : base(programScheduleRepository) { - _programScheduleRepository = programScheduleRepository; + _dbContextFactory = dbContextFactory; _channel = channel; } - public Task> Handle( + public async Task> Handle( AddProgramScheduleItem request, - CancellationToken cancellationToken) => - Validate(request) - .MapT(programSchedule => PersistItem(request, programSchedule)) - .Bind(v => v.ToEitherAsync()); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + Validation validation = await Validate(dbContext, request); + return await validation.Apply(ps => PersistItem(dbContext, request, ps)); + } private async Task PersistItem( + TvContext dbContext, AddProgramScheduleItem request, ProgramSchedule programSchedule) { @@ -43,7 +46,7 @@ namespace ErsatzTV.Application.ProgramSchedules.Commands ProgramScheduleItem item = BuildItem(programSchedule, nextIndex, request); programSchedule.Items.Add(item); - await _programScheduleRepository.Update(programSchedule); + await dbContext.SaveChangesAsync(); // rebuild any playouts that use this schedule foreach (Playout playout in programSchedule.Playouts) @@ -54,8 +57,10 @@ namespace ErsatzTV.Application.ProgramSchedules.Commands return ProjectToViewModel(item); } - private Task> Validate(AddProgramScheduleItem request) => - ProgramScheduleMustExist(request.ProgramScheduleId) + private static Task> Validate( + TvContext dbContext, + AddProgramScheduleItem request) => + ProgramScheduleMustExist(dbContext, request.ProgramScheduleId) .BindT(programSchedule => PlayoutModeMustBeValid(request, programSchedule)); } } diff --git a/ErsatzTV.Application/ProgramSchedules/Commands/CreateProgramSchedule.cs b/ErsatzTV.Application/ProgramSchedules/Commands/CreateProgramSchedule.cs index 507cf0deb..13ab124a3 100644 --- a/ErsatzTV.Application/ProgramSchedules/Commands/CreateProgramSchedule.cs +++ b/ErsatzTV.Application/ProgramSchedules/Commands/CreateProgramSchedule.cs @@ -9,5 +9,5 @@ namespace ErsatzTV.Application.ProgramSchedules.Commands string Name, PlaybackOrder MediaCollectionPlaybackOrder, bool KeepMultiPartEpisodesTogether, - bool TreatCollectionsAsShows) : IRequest>; + bool TreatCollectionsAsShows) : IRequest>; } diff --git a/ErsatzTV.Application/ProgramSchedules/Commands/CreateProgramScheduleHandler.cs b/ErsatzTV.Application/ProgramSchedules/Commands/CreateProgramScheduleHandler.cs index eb54c81ec..7c4a2d59d 100644 --- a/ErsatzTV.Application/ProgramSchedules/Commands/CreateProgramScheduleHandler.cs +++ b/ErsatzTV.Application/ProgramSchedules/Commands/CreateProgramScheduleHandler.cs @@ -1,63 +1,74 @@ -using System.Collections.Generic; -using System.Linq; -using System.Threading; +using System.Threading; using System.Threading.Tasks; using ErsatzTV.Core; using ErsatzTV.Core.Domain; -using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; using LanguageExt; using MediatR; -using static ErsatzTV.Application.ProgramSchedules.Mapper; +using Microsoft.EntityFrameworkCore; using static LanguageExt.Prelude; +using ValidationT_AsyncSync_Extensions = LanguageExt.ValidationT_AsyncSync_Extensions; namespace ErsatzTV.Application.ProgramSchedules.Commands { - public class - CreateProgramScheduleHandler : IRequestHandler> + public class CreateProgramScheduleHandler : + IRequestHandler> { - private readonly IProgramScheduleRepository _programScheduleRepository; + private readonly IDbContextFactory _dbContextFactory; - public CreateProgramScheduleHandler(IProgramScheduleRepository programScheduleRepository) => - _programScheduleRepository = programScheduleRepository; + public CreateProgramScheduleHandler(IDbContextFactory dbContextFactory) => + _dbContextFactory = dbContextFactory; - public Task> Handle( + public async Task> Handle( CreateProgramSchedule request, - CancellationToken cancellationToken) => - Validate(request) - .MapT(PersistProgramSchedule) - .Bind(v => v.ToEitherAsync()); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); - private Task PersistProgramSchedule(ProgramSchedule c) => - _programScheduleRepository.Add(c).Map(ProjectToViewModel); + Validation validation = await Validate(dbContext, request); + return await validation.Apply(ps => PersistProgramSchedule(dbContext, ps)); + } - private Task> Validate(CreateProgramSchedule request) => - ValidateName(request) - .MapT( - name => + private static async Task PersistProgramSchedule( + TvContext dbContext, + ProgramSchedule programSchedule) + { + await dbContext.ProgramSchedules.AddAsync(programSchedule); + await dbContext.SaveChangesAsync(); + return new CreateProgramScheduleResult(programSchedule.Id); + } + + private static Task> Validate( + TvContext dbContext, + CreateProgramSchedule request) => + ValidationT_AsyncSync_Extensions.MapT( + ValidateName(dbContext, request), + name => + { + bool keepMultiPartEpisodesTogether = + request.MediaCollectionPlaybackOrder == PlaybackOrder.Shuffle && + request.KeepMultiPartEpisodesTogether; + return new ProgramSchedule { - bool keepMultiPartEpisodesTogether = - request.MediaCollectionPlaybackOrder == PlaybackOrder.Shuffle && - request.KeepMultiPartEpisodesTogether; - return new ProgramSchedule - { - Name = name, - MediaCollectionPlaybackOrder = request.MediaCollectionPlaybackOrder, - KeepMultiPartEpisodesTogether = keepMultiPartEpisodesTogether, - TreatCollectionsAsShows = keepMultiPartEpisodesTogether && request.TreatCollectionsAsShows - }; - }); + Name = name, + MediaCollectionPlaybackOrder = request.MediaCollectionPlaybackOrder, + KeepMultiPartEpisodesTogether = keepMultiPartEpisodesTogether, + TreatCollectionsAsShows = keepMultiPartEpisodesTogether && request.TreatCollectionsAsShows + }; + }); - private async Task> ValidateName(CreateProgramSchedule createProgramSchedule) + private static async Task> ValidateName( + TvContext dbContext, + CreateProgramSchedule createProgramSchedule) { - List allNames = await _programScheduleRepository.GetAll() - .Map(list => list.Map(c => c.Name).ToList()); - Validation result1 = createProgramSchedule.NotEmpty(c => c.Name) .Bind(_ => createProgramSchedule.NotLongerThan(50)(c => c.Name)); - var result2 = Optional(createProgramSchedule.Name) - .Filter(name => !allNames.Contains(name)) + int duplicateNameCount = await dbContext.ProgramSchedules + .CountAsync(ps => ps.Name == createProgramSchedule.Name); + + var result2 = Optional(duplicateNameCount) + .Filter(count => count == 0) .ToValidation("Schedule name must be unique"); return (result1, result2).Apply((_, _) => createProgramSchedule.Name); diff --git a/ErsatzTV.Application/ProgramSchedules/Commands/CreateProgramScheduleResult.cs b/ErsatzTV.Application/ProgramSchedules/Commands/CreateProgramScheduleResult.cs new file mode 100644 index 000000000..bb6b51cdf --- /dev/null +++ b/ErsatzTV.Application/ProgramSchedules/Commands/CreateProgramScheduleResult.cs @@ -0,0 +1,4 @@ +namespace ErsatzTV.Application.ProgramSchedules.Commands +{ + public record CreateProgramScheduleResult(int ProgramScheduleId) : EntityIdResult(ProgramScheduleId); +} diff --git a/ErsatzTV.Application/ProgramSchedules/Commands/DeleteProgramSchedule.cs b/ErsatzTV.Application/ProgramSchedules/Commands/DeleteProgramSchedule.cs index 423f1a598..b7f40e3b3 100644 --- a/ErsatzTV.Application/ProgramSchedules/Commands/DeleteProgramSchedule.cs +++ b/ErsatzTV.Application/ProgramSchedules/Commands/DeleteProgramSchedule.cs @@ -1,9 +1,8 @@ -using System.Threading.Tasks; -using ErsatzTV.Core; +using ErsatzTV.Core; using LanguageExt; using MediatR; namespace ErsatzTV.Application.ProgramSchedules.Commands { - public record DeleteProgramSchedule(int ProgramScheduleId) : IRequest>; + public record DeleteProgramSchedule(int ProgramScheduleId) : IRequest>; } diff --git a/ErsatzTV.Application/ProgramSchedules/Commands/DeleteProgramScheduleHandler.cs b/ErsatzTV.Application/ProgramSchedules/Commands/DeleteProgramScheduleHandler.cs index 8cf4b9ed9..3a69ce2e4 100644 --- a/ErsatzTV.Application/ProgramSchedules/Commands/DeleteProgramScheduleHandler.cs +++ b/ErsatzTV.Application/ProgramSchedules/Commands/DeleteProgramScheduleHandler.cs @@ -1,32 +1,43 @@ using System.Threading; using System.Threading.Tasks; using ErsatzTV.Core; -using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Core.Domain; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; using MediatR; +using Microsoft.EntityFrameworkCore; +using Unit = LanguageExt.Unit; namespace ErsatzTV.Application.ProgramSchedules.Commands { - public class DeleteProgramScheduleHandler : IRequestHandler> + public class DeleteProgramScheduleHandler : IRequestHandler> { - private readonly IProgramScheduleRepository _programScheduleRepository; + private readonly IDbContextFactory _dbContextFactory; - public DeleteProgramScheduleHandler(IProgramScheduleRepository programScheduleRepository) => - _programScheduleRepository = programScheduleRepository; + public DeleteProgramScheduleHandler(IDbContextFactory dbContextFactory) => + _dbContextFactory = dbContextFactory; - public async Task> Handle( + public async Task> Handle( DeleteProgramSchedule request, - CancellationToken cancellationToken) => - (await ProgramScheduleMustExist(request)) - .Map(DoDeletion) - .ToEither(); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + Validation validation = await ProgramScheduleMustExist(dbContext, request); + return await validation.Apply(ps => DoDeletion(dbContext, ps)); + } - private Task DoDeletion(int programScheduleId) => _programScheduleRepository.Delete(programScheduleId); + private static Task DoDeletion(TvContext dbContext, ProgramSchedule programSchedule) + { + dbContext.ProgramSchedules.Remove(programSchedule); + return dbContext.SaveChangesAsync().ToUnit(); + } - private async Task> ProgramScheduleMustExist( - DeleteProgramSchedule deleteProgramSchedule) => - (await _programScheduleRepository.Get(deleteProgramSchedule.ProgramScheduleId)) - .ToValidation($"ProgramSchedule {deleteProgramSchedule.ProgramScheduleId} does not exist.") - .Map(c => c.Id); + private Task> ProgramScheduleMustExist( + TvContext dbContext, + DeleteProgramSchedule request) => + dbContext.ProgramSchedules + .SelectOneAsync(ps => ps.Id, ps => ps.Id == request.ProgramScheduleId) + .Map(o => o.ToValidation($"ProgramSchedule {request.ProgramScheduleId} does not exist.")); } } diff --git a/ErsatzTV.Application/ProgramSchedules/Commands/ProgramScheduleItemCommandBase.cs b/ErsatzTV.Application/ProgramSchedules/Commands/ProgramScheduleItemCommandBase.cs index 998fbd00e..d22a0b37d 100644 --- a/ErsatzTV.Application/ProgramSchedules/Commands/ProgramScheduleItemCommandBase.cs +++ b/ErsatzTV.Application/ProgramSchedules/Commands/ProgramScheduleItemCommandBase.cs @@ -2,23 +2,25 @@ using System.Threading.Tasks; using ErsatzTV.Core; using ErsatzTV.Core.Domain; -using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; +using Microsoft.EntityFrameworkCore; namespace ErsatzTV.Application.ProgramSchedules.Commands { public abstract class ProgramScheduleItemCommandBase { - private readonly IProgramScheduleRepository _programScheduleRepository; - - protected ProgramScheduleItemCommandBase(IProgramScheduleRepository programScheduleRepository) => - _programScheduleRepository = programScheduleRepository; - - protected async Task> ProgramScheduleMustExist(int programScheduleId) => - (await _programScheduleRepository.GetWithPlayouts(programScheduleId)) - .ToValidation("[ProgramScheduleId] does not exist."); - - protected Validation PlayoutModeMustBeValid( + protected static Task> ProgramScheduleMustExist( + TvContext dbContext, + int programScheduleId) => + dbContext.ProgramSchedules + .Include(ps => ps.Items) + .Include(ps => ps.Playouts) + .SelectOneAsync(ps => ps.Id, ps => ps.Id == programScheduleId) + .Map(o => o.ToValidation("[ProgramScheduleId] does not exist.")); + + protected static Validation PlayoutModeMustBeValid( IProgramScheduleItemRequest item, ProgramSchedule programSchedule) { diff --git a/ErsatzTV.Application/ProgramSchedules/Commands/ReplaceProgramScheduleItemsHandler.cs b/ErsatzTV.Application/ProgramSchedules/Commands/ReplaceProgramScheduleItemsHandler.cs index fcd8a7d99..c586f1b0b 100644 --- a/ErsatzTV.Application/ProgramSchedules/Commands/ReplaceProgramScheduleItemsHandler.cs +++ b/ErsatzTV.Application/ProgramSchedules/Commands/ReplaceProgramScheduleItemsHandler.cs @@ -6,43 +6,46 @@ using System.Threading.Tasks; using ErsatzTV.Application.Playouts.Commands; using ErsatzTV.Core; using ErsatzTV.Core.Domain; -using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; using LanguageExt; using MediatR; +using Microsoft.EntityFrameworkCore; using static ErsatzTV.Application.ProgramSchedules.Mapper; namespace ErsatzTV.Application.ProgramSchedules.Commands { public class ReplaceProgramScheduleItemsHandler : ProgramScheduleItemCommandBase, - IRequestHandler>> + IRequestHandler>> { + private readonly IDbContextFactory _dbContextFactory; private readonly ChannelWriter _channel; - private readonly IProgramScheduleRepository _programScheduleRepository; public ReplaceProgramScheduleItemsHandler( - IProgramScheduleRepository programScheduleRepository, + IDbContextFactory dbContextFactory, ChannelWriter channel) - : base(programScheduleRepository) { - _programScheduleRepository = programScheduleRepository; + _dbContextFactory = dbContextFactory; _channel = channel; } - public Task>> Handle( + public async Task>> Handle( ReplaceProgramScheduleItems request, - CancellationToken cancellationToken) => - Validate(request) - .MapT(programSchedule => PersistItems(request, programSchedule)) - .Bind(v => v.ToEitherAsync()); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + Validation validation = await Validate(dbContext, request); + return await validation.Apply(ps => PersistItems(dbContext, request, ps)); + } private async Task> PersistItems( + TvContext dbContext, ReplaceProgramScheduleItems request, ProgramSchedule programSchedule) { + dbContext.RemoveRange(programSchedule.Items); programSchedule.Items = request.Items.Map(i => BuildItem(programSchedule, i.Index, i)).ToList(); - await _programScheduleRepository.Update(programSchedule); + await dbContext.SaveChangesAsync(); // rebuild any playouts that use this schedule foreach (Playout playout in programSchedule.Playouts) @@ -53,12 +56,14 @@ namespace ErsatzTV.Application.ProgramSchedules.Commands return programSchedule.Items.Map(ProjectToViewModel); } - private Task> Validate(ReplaceProgramScheduleItems request) => - ProgramScheduleMustExist(request.ProgramScheduleId) + private Task> Validate( + TvContext dbContext, + ReplaceProgramScheduleItems request) => + ProgramScheduleMustExist(dbContext, request.ProgramScheduleId) .BindT(programSchedule => PlayoutModesMustBeValid(request, programSchedule)) .BindT(programSchedule => CollectionTypesMustBeValid(request, programSchedule)); - private Validation PlayoutModesMustBeValid( + private static Validation PlayoutModesMustBeValid( ReplaceProgramScheduleItems request, ProgramSchedule programSchedule) => request.Items.Map(item => PlayoutModeMustBeValid(item, programSchedule)).Sequence() diff --git a/ErsatzTV.Application/ProgramSchedules/Commands/UpdateProgramSchedule.cs b/ErsatzTV.Application/ProgramSchedules/Commands/UpdateProgramSchedule.cs index c9440a1d6..95d3bcf81 100644 --- a/ErsatzTV.Application/ProgramSchedules/Commands/UpdateProgramSchedule.cs +++ b/ErsatzTV.Application/ProgramSchedules/Commands/UpdateProgramSchedule.cs @@ -11,5 +11,5 @@ namespace ErsatzTV.Application.ProgramSchedules.Commands string Name, PlaybackOrder MediaCollectionPlaybackOrder, bool KeepMultiPartEpisodesTogether, - bool TreatCollectionsAsShows) : IRequest>; + bool TreatCollectionsAsShows) : IRequest>; } diff --git a/ErsatzTV.Application/ProgramSchedules/Commands/UpdateProgramScheduleHandler.cs b/ErsatzTV.Application/ProgramSchedules/Commands/UpdateProgramScheduleHandler.cs index 2b0e9656f..3c5cbc3bc 100644 --- a/ErsatzTV.Application/ProgramSchedules/Commands/UpdateProgramScheduleHandler.cs +++ b/ErsatzTV.Application/ProgramSchedules/Commands/UpdateProgramScheduleHandler.cs @@ -1,79 +1,94 @@ -using System.Threading; +using System.Collections.Generic; +using System.Threading; using System.Threading.Channels; using System.Threading.Tasks; using ErsatzTV.Application.Playouts.Commands; using ErsatzTV.Core; using ErsatzTV.Core.Domain; -using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; using MediatR; -using static ErsatzTV.Application.ProgramSchedules.Mapper; +using Microsoft.EntityFrameworkCore; namespace ErsatzTV.Application.ProgramSchedules.Commands { - public class - UpdateProgramScheduleHandler : IRequestHandler> + public class UpdateProgramScheduleHandler : + IRequestHandler> { private readonly ChannelWriter _channel; - private readonly IProgramScheduleRepository _programScheduleRepository; + private readonly IDbContextFactory _dbContextFactory; public UpdateProgramScheduleHandler( - IProgramScheduleRepository programScheduleRepository, + IDbContextFactory dbContextFactory, ChannelWriter channel) { - _programScheduleRepository = programScheduleRepository; + _dbContextFactory = dbContextFactory; _channel = channel; } - public Task> Handle( + public async Task> Handle( UpdateProgramSchedule request, - CancellationToken cancellationToken) => - Validate(request) - .MapT(c => ApplyUpdateRequest(c, request)) - .Bind(v => v.ToEitherAsync()); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + + Validation validation = await Validate(dbContext, request); + return await validation.Apply(ps => ApplyUpdateRequest(dbContext, ps, request)); + } - private async Task ApplyUpdateRequest( + private async Task ApplyUpdateRequest( + TvContext dbContext, ProgramSchedule programSchedule, - UpdateProgramSchedule update) + UpdateProgramSchedule request) { // we need to rebuild playouts if the playback order or keep multi-episodes has been modified bool needToRebuildPlayout = - programSchedule.MediaCollectionPlaybackOrder != update.MediaCollectionPlaybackOrder || - programSchedule.KeepMultiPartEpisodesTogether != update.KeepMultiPartEpisodesTogether || - programSchedule.TreatCollectionsAsShows != update.TreatCollectionsAsShows; + programSchedule.MediaCollectionPlaybackOrder != request.MediaCollectionPlaybackOrder || + programSchedule.KeepMultiPartEpisodesTogether != request.KeepMultiPartEpisodesTogether || + programSchedule.TreatCollectionsAsShows != request.TreatCollectionsAsShows; - programSchedule.Name = update.Name; - programSchedule.MediaCollectionPlaybackOrder = update.MediaCollectionPlaybackOrder; + programSchedule.Name = request.Name; + programSchedule.MediaCollectionPlaybackOrder = request.MediaCollectionPlaybackOrder; programSchedule.KeepMultiPartEpisodesTogether = - update.MediaCollectionPlaybackOrder == PlaybackOrder.Shuffle && - update.KeepMultiPartEpisodesTogether; + request.MediaCollectionPlaybackOrder == PlaybackOrder.Shuffle && + request.KeepMultiPartEpisodesTogether; programSchedule.TreatCollectionsAsShows = programSchedule.KeepMultiPartEpisodesTogether && - update.TreatCollectionsAsShows; - await _programScheduleRepository.Update(programSchedule); + request.TreatCollectionsAsShows; + + await dbContext.SaveChangesAsync(); if (needToRebuildPlayout) { - foreach (Playout playout in programSchedule.Playouts) + List playoutIds = await dbContext.Playouts + .Filter(p => p.ProgramScheduleId == programSchedule.Id) + .Map(p => p.Id) + .ToListAsync(); + + foreach (int playoutId in playoutIds) { - await _channel.WriteAsync(new BuildPlayout(playout.Id, true)); + await _channel.WriteAsync(new BuildPlayout(playoutId, true)); } } - return ProjectToViewModel(programSchedule); + return new UpdateProgramScheduleResult(programSchedule.Id); } - private async Task> Validate(UpdateProgramSchedule request) => - (await ProgramScheduleMustExist(request), ValidateName(request)) - .Apply((programScheduleToUpdate, _) => programScheduleToUpdate); + private static async Task> Validate( + TvContext dbContext, + UpdateProgramSchedule request) => + (await ProgramScheduleMustExist(dbContext, request), ValidateName(request)) + .Apply((programSchedule, _) => programSchedule); - private async Task> ProgramScheduleMustExist( - UpdateProgramSchedule updateProgramSchedule) => - (await _programScheduleRepository.GetWithPlayouts(updateProgramSchedule.ProgramScheduleId)) - .ToValidation("ProgramSchedule does not exist."); + private static Task> ProgramScheduleMustExist( + TvContext dbContext, + UpdateProgramSchedule request) => + dbContext.ProgramSchedules + .SelectOneAsync(ps => ps.Id, ps => ps.Id == request.ProgramScheduleId) + .Map(o => o.ToValidation("ProgramSchedule does not exist")); - private Validation ValidateName(UpdateProgramSchedule updateProgramSchedule) => - updateProgramSchedule.NotEmpty(c => c.Name) - .Bind(_ => updateProgramSchedule.NotLongerThan(50)(c => c.Name)); + private static Validation ValidateName(UpdateProgramSchedule request) => + request.NotEmpty(c => c.Name) + .Bind(_ => request.NotLongerThan(50)(c => c.Name)); } } diff --git a/ErsatzTV.Application/ProgramSchedules/Commands/UpdateProgramScheduleResult.cs b/ErsatzTV.Application/ProgramSchedules/Commands/UpdateProgramScheduleResult.cs new file mode 100644 index 000000000..4e15e5d07 --- /dev/null +++ b/ErsatzTV.Application/ProgramSchedules/Commands/UpdateProgramScheduleResult.cs @@ -0,0 +1,4 @@ +namespace ErsatzTV.Application.ProgramSchedules.Commands +{ + public record UpdateProgramScheduleResult(int ProgramScheduleId) : EntityIdResult(ProgramScheduleId); +} diff --git a/ErsatzTV.Application/ProgramSchedules/Queries/GetAllProgramSchedulesHandler.cs b/ErsatzTV.Application/ProgramSchedules/Queries/GetAllProgramSchedulesHandler.cs index 2f2e7ea7b..711f28749 100644 --- a/ErsatzTV.Application/ProgramSchedules/Queries/GetAllProgramSchedulesHandler.cs +++ b/ErsatzTV.Application/ProgramSchedules/Queries/GetAllProgramSchedulesHandler.cs @@ -1,23 +1,33 @@ using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; -using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; using MediatR; -using static ErsatzTV.Application.ProgramSchedules.Mapper; +using Microsoft.EntityFrameworkCore; namespace ErsatzTV.Application.ProgramSchedules.Queries { public class GetAllProgramSchedulesHandler : IRequestHandler> { - private readonly IProgramScheduleRepository _programScheduleRepository; + private readonly IDbContextFactory _dbContextFactory; - public GetAllProgramSchedulesHandler(IProgramScheduleRepository programScheduleRepository) => - _programScheduleRepository = programScheduleRepository; + public GetAllProgramSchedulesHandler(IDbContextFactory dbContextFactory) => + _dbContextFactory = dbContextFactory; public async Task> Handle( GetAllProgramSchedules request, - CancellationToken cancellationToken) => - (await _programScheduleRepository.GetAll()).Map(ProjectToViewModel).ToList(); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + return await dbContext.ProgramSchedules + .Map( + ps => new ProgramScheduleViewModel( + ps.Id, + ps.Name, + ps.MediaCollectionPlaybackOrder, + ps.KeepMultiPartEpisodesTogether, + ps.TreatCollectionsAsShows)) + .ToListAsync(cancellationToken); + } } } diff --git a/ErsatzTV.Application/ProgramSchedules/Queries/GetProgramScheduleByIdHandler.cs b/ErsatzTV.Application/ProgramSchedules/Queries/GetProgramScheduleByIdHandler.cs index 57e2dca01..e5e080d0a 100644 --- a/ErsatzTV.Application/ProgramSchedules/Queries/GetProgramScheduleByIdHandler.cs +++ b/ErsatzTV.Application/ProgramSchedules/Queries/GetProgramScheduleByIdHandler.cs @@ -1,24 +1,30 @@ using System.Threading; using System.Threading.Tasks; -using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; using MediatR; +using Microsoft.EntityFrameworkCore; using static ErsatzTV.Application.ProgramSchedules.Mapper; namespace ErsatzTV.Application.ProgramSchedules.Queries { - public class - GetProgramScheduleByIdHandler : IRequestHandler> + public class GetProgramScheduleByIdHandler : + IRequestHandler> { - private readonly IProgramScheduleRepository _programScheduleRepository; + private readonly IDbContextFactory _dbContextFactory; - public GetProgramScheduleByIdHandler(IProgramScheduleRepository programScheduleRepository) => - _programScheduleRepository = programScheduleRepository; + public GetProgramScheduleByIdHandler(IDbContextFactory dbContextFactory) => + _dbContextFactory = dbContextFactory; - public Task> Handle( + public async Task> Handle( GetProgramScheduleById request, - CancellationToken cancellationToken) => - _programScheduleRepository.Get(request.Id) + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + return await dbContext.ProgramSchedules + .SelectOneAsync(ps => ps.Id, ps => ps.Id == request.Id) .MapT(ProjectToViewModel); + } } } diff --git a/ErsatzTV.Application/ProgramSchedules/Queries/GetProgramScheduleItems.cs b/ErsatzTV.Application/ProgramSchedules/Queries/GetProgramScheduleItems.cs index 8e75be5e3..9659d054c 100644 --- a/ErsatzTV.Application/ProgramSchedules/Queries/GetProgramScheduleItems.cs +++ b/ErsatzTV.Application/ProgramSchedules/Queries/GetProgramScheduleItems.cs @@ -1,8 +1,7 @@ using System.Collections.Generic; -using LanguageExt; using MediatR; namespace ErsatzTV.Application.ProgramSchedules.Queries { - public record GetProgramScheduleItems(int Id) : IRequest>>; + public record GetProgramScheduleItems(int Id) : IRequest>; } diff --git a/ErsatzTV.Application/ProgramSchedules/Queries/GetProgramScheduleItemsHandler.cs b/ErsatzTV.Application/ProgramSchedules/Queries/GetProgramScheduleItemsHandler.cs index 724835415..f2d8d0add 100644 --- a/ErsatzTV.Application/ProgramSchedules/Queries/GetProgramScheduleItemsHandler.cs +++ b/ErsatzTV.Application/ProgramSchedules/Queries/GetProgramScheduleItemsHandler.cs @@ -1,25 +1,50 @@ using System.Collections.Generic; +using System.Linq; using System.Threading; using System.Threading.Tasks; -using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Core.Domain; +using ErsatzTV.Infrastructure.Data; using LanguageExt; using MediatR; +using Microsoft.EntityFrameworkCore; using static ErsatzTV.Application.ProgramSchedules.Mapper; namespace ErsatzTV.Application.ProgramSchedules.Queries { - public class GetProgramScheduleItemsHandler : IRequestHandler>> + public class GetProgramScheduleItemsHandler : + IRequestHandler> { - private readonly IProgramScheduleRepository _programScheduleRepository; + private readonly IDbContextFactory _dbContextFactory; - public GetProgramScheduleItemsHandler(IProgramScheduleRepository programScheduleRepository) => - _programScheduleRepository = programScheduleRepository; + public GetProgramScheduleItemsHandler(IDbContextFactory dbContextFactory) => + _dbContextFactory = dbContextFactory; - public Task>> Handle( + public async Task> Handle( GetProgramScheduleItems request, - CancellationToken cancellationToken) => - _programScheduleRepository.GetItems(request.Id) - .MapT(programScheduleItems => programScheduleItems.Map(ProjectToViewModel)); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + return await dbContext.ProgramScheduleItems + .Filter(psi => psi.ProgramScheduleId == request.Id) + .Include(i => i.Collection) + .Include(i => i.MediaItem) + .ThenInclude(i => (i as Movie).MovieMetadata) + .ThenInclude(mm => mm.Artwork) + .Include(i => i.MediaItem) + .ThenInclude(i => (i as Season).SeasonMetadata) + .ThenInclude(sm => sm.Artwork) + .Include(i => i.MediaItem) + .ThenInclude(i => (i as Season).Show) + .ThenInclude(s => s.ShowMetadata) + .ThenInclude(sm => sm.Artwork) + .Include(i => i.MediaItem) + .ThenInclude(i => (i as Show).ShowMetadata) + .ThenInclude(sm => sm.Artwork) + .Include(i => i.MediaItem) + .ThenInclude(i => (i as Artist).ArtistMetadata) + .ThenInclude(am => am.Artwork) + .ToListAsync(cancellationToken) + .Map(programScheduleItems => programScheduleItems.Map(ProjectToViewModel).ToList()); + } } } diff --git a/ErsatzTV.Application/Resolutions/Queries/GetAllResolutionsHandler.cs b/ErsatzTV.Application/Resolutions/Queries/GetAllResolutionsHandler.cs index 784ea62ee..b702c8694 100644 --- a/ErsatzTV.Application/Resolutions/Queries/GetAllResolutionsHandler.cs +++ b/ErsatzTV.Application/Resolutions/Queries/GetAllResolutionsHandler.cs @@ -2,21 +2,29 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; using LanguageExt; using MediatR; +using Microsoft.EntityFrameworkCore; using static ErsatzTV.Application.Resolutions.Mapper; namespace ErsatzTV.Application.Resolutions.Queries { public class GetAllResolutionsHandler : IRequestHandler> { - private readonly IResolutionRepository _resolutionRepository; + private readonly IDbContextFactory _dbContextFactory; - public GetAllResolutionsHandler(IResolutionRepository resolutionRepository) => - _resolutionRepository = resolutionRepository; + public GetAllResolutionsHandler(IDbContextFactory dbContextFactory) => + _dbContextFactory = dbContextFactory; - public Task> Handle(GetAllResolutions request, CancellationToken cancellationToken) => - _resolutionRepository.GetAll().Map(resolutions => resolutions.Map(ProjectToViewModel).ToList()); + public async Task> Handle( + GetAllResolutions request, + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + return await dbContext.Resolutions + .ToListAsync(cancellationToken) + .Map(list => list.Map(ProjectToViewModel).ToList()); + } } } diff --git a/ErsatzTV.Application/Search/Commands/RebuildSearchIndexHandler.cs b/ErsatzTV.Application/Search/Commands/RebuildSearchIndexHandler.cs index 993ab1a7a..40806ec61 100644 --- a/ErsatzTV.Application/Search/Commands/RebuildSearchIndexHandler.cs +++ b/ErsatzTV.Application/Search/Commands/RebuildSearchIndexHandler.cs @@ -49,23 +49,7 @@ namespace ErsatzTV.Application.Search.Commands List itemIds = await _searchRepository.GetItemIdsToIndex(); await _searchIndex.Rebuild(_searchRepository, itemIds); - Option maybeVersion = - await _configElementRepository.Get(ConfigElementKey.SearchIndexVersion); - await maybeVersion.Match( - version => - { - version.Value = _searchIndex.Version.ToString(); - return _configElementRepository.Update(version); - }, - () => - { - var configElement = new ConfigElement - { - Key = ConfigElementKey.SearchIndexVersion.Key, - Value = _searchIndex.Version.ToString() - }; - return _configElementRepository.Add(configElement); - }); + await _configElementRepository.Upsert(ConfigElementKey.SearchIndexVersion, _searchIndex.Version); _logger.LogDebug("Done migrating search index"); } diff --git a/ErsatzTV.Application/Streaming/Queries/FFmpegProcessHandler.cs b/ErsatzTV.Application/Streaming/Queries/FFmpegProcessHandler.cs index efa54ebb6..748b7c5a3 100644 --- a/ErsatzTV.Application/Streaming/Queries/FFmpegProcessHandler.cs +++ b/ErsatzTV.Application/Streaming/Queries/FFmpegProcessHandler.cs @@ -5,9 +5,11 @@ using System.Threading; using System.Threading.Tasks; using ErsatzTV.Core; using ErsatzTV.Core.Domain; -using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; using MediatR; +using Microsoft.EntityFrameworkCore; using static LanguageExt.Prelude; namespace ErsatzTV.Application.Streaming.Queries @@ -15,46 +17,55 @@ namespace ErsatzTV.Application.Streaming.Queries public abstract class FFmpegProcessHandler : IRequestHandler> where T : FFmpegProcessRequest { - private readonly IChannelRepository _channelRepository; - private readonly IConfigElementRepository _configElementRepository; + private readonly IDbContextFactory _dbContextFactory; - protected FFmpegProcessHandler( - IChannelRepository channelRepository, - IConfigElementRepository configElementRepository) + protected FFmpegProcessHandler(IDbContextFactory dbContextFactory) => + _dbContextFactory = dbContextFactory; + + public async Task> Handle(T request, CancellationToken cancellationToken) { - _channelRepository = channelRepository; - _configElementRepository = configElementRepository; + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + Validation> validation = await Validate(dbContext, request); + return await validation.Match( + tuple => GetProcess(dbContext, request, tuple.Item1, tuple.Item2), + error => Task.FromResult>(error.Join())); } - public Task> Handle(T request, CancellationToken cancellationToken) => - Validate(request) - .Map(v => v.ToEither>()) - .BindT(tuple => GetProcess(request, tuple.Item1, tuple.Item2)); - - protected abstract Task> GetProcess(T request, Channel channel, string ffmpegPath); + protected abstract Task> GetProcess( + TvContext dbContext, + T request, + Channel channel, + string ffmpegPath); - private async Task>> Validate(T request) => - (await ChannelMustExist(request), await FFmpegPathMustExist()) + private static async Task>> Validate( + TvContext dbContext, + T request) => + (await ChannelMustExist(dbContext, request), await FFmpegPathMustExist(dbContext)) .Apply((channel, ffmpegPath) => Tuple(channel, ffmpegPath)); - private async Task> ChannelMustExist(T request) => - (await _channelRepository.GetByNumber(request.ChannelNumber)) - .Map( - channel => - { - channel.StreamingMode = request.Mode.ToLowerInvariant() switch + private static Task> ChannelMustExist(TvContext dbContext, T request) => + dbContext.Channels + .Include(c => c.FFmpegProfile) + .ThenInclude(p => p.Resolution) + .Include(c => c.Artwork) + .Include(c => c.Watermark) + .SelectOneAsync(c => c.Number, c => c.Number == request.ChannelNumber) + .MapT( + channel => { - "hls-direct" => StreamingMode.HttpLiveStreamingDirect, - "ts" => StreamingMode.TransportStream, - _ => channel.StreamingMode - }; + channel.StreamingMode = request.Mode.ToLowerInvariant() switch + { + "hls-direct" => StreamingMode.HttpLiveStreamingDirect, + "ts" => StreamingMode.TransportStream, + _ => channel.StreamingMode + }; - return channel; - }) - .ToValidation($"Channel number {request.ChannelNumber} does not exist."); + return channel; + }) + .Map(o => o.ToValidation($"Channel number {request.ChannelNumber} does not exist.")); - private Task> FFmpegPathMustExist() => - _configElementRepository.GetValue(ConfigElementKey.FFmpegPath) + private static Task> FFmpegPathMustExist(TvContext dbContext) => + dbContext.ConfigElements.GetValue(ConfigElementKey.FFmpegPath) .FilterT(File.Exists) .Map(maybePath => maybePath.ToValidation("FFmpeg path does not exist on filesystem")); } diff --git a/ErsatzTV.Application/Streaming/Queries/GetConcatProcessByChannelNumberHandler.cs b/ErsatzTV.Application/Streaming/Queries/GetConcatProcessByChannelNumberHandler.cs index f6bbf17f8..0762056f0 100644 --- a/ErsatzTV.Application/Streaming/Queries/GetConcatProcessByChannelNumberHandler.cs +++ b/ErsatzTV.Application/Streaming/Queries/GetConcatProcessByChannelNumberHandler.cs @@ -4,36 +4,36 @@ using System.Threading.Tasks; using ErsatzTV.Core; using ErsatzTV.Core.Domain; using ErsatzTV.Core.FFmpeg; -using ErsatzTV.Core.Interfaces.Repositories; using ErsatzTV.Core.Interfaces.Runtime; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; +using Microsoft.EntityFrameworkCore; namespace ErsatzTV.Application.Streaming.Queries { public class GetConcatProcessByChannelNumberHandler : FFmpegProcessHandler { - private readonly IConfigElementRepository _configElementRepository; private readonly FFmpegProcessService _ffmpegProcessService; private readonly IRuntimeInfo _runtimeInfo; public GetConcatProcessByChannelNumberHandler( - IChannelRepository channelRepository, - IConfigElementRepository configElementRepository, + IDbContextFactory dbContextFactory, FFmpegProcessService ffmpegProcessService, IRuntimeInfo runtimeInfo) - : base(channelRepository, configElementRepository) + : base(dbContextFactory) { - _configElementRepository = configElementRepository; _ffmpegProcessService = ffmpegProcessService; _runtimeInfo = runtimeInfo; } protected override async Task> GetProcess( + TvContext dbContext, GetConcatProcessByChannelNumber request, Channel channel, string ffmpegPath) { - bool saveReports = !_runtimeInfo.IsOSPlatform(OSPlatform.Windows) && await _configElementRepository + bool saveReports = !_runtimeInfo.IsOSPlatform(OSPlatform.Windows) && await dbContext.ConfigElements .GetValue(ConfigElementKey.FFmpegSaveReports) .Map(result => result.IfNone(false)); diff --git a/ErsatzTV.Application/Streaming/Queries/GetHlsPlaylistByChannelNumberHandler.cs b/ErsatzTV.Application/Streaming/Queries/GetHlsPlaylistByChannelNumberHandler.cs index 60818c9e2..c42a627fc 100644 --- a/ErsatzTV.Application/Streaming/Queries/GetHlsPlaylistByChannelNumberHandler.cs +++ b/ErsatzTV.Application/Streaming/Queries/GetHlsPlaylistByChannelNumberHandler.cs @@ -3,73 +3,83 @@ using System.Threading; using System.Threading.Tasks; using ErsatzTV.Core; using ErsatzTV.Core.Domain; -using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; using MediatR; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Caching.Memory; -using Serilog; namespace ErsatzTV.Application.Streaming.Queries { - public class - GetHlsPlaylistByChannelNumberHandler : IRequestHandler> + public class GetHlsPlaylistByChannelNumberHandler : + IRequestHandler> { - private readonly IChannelRepository _channelRepository; + private readonly IDbContextFactory _dbContextFactory; private readonly IMemoryCache _memoryCache; - private readonly IPlayoutRepository _playoutRepository; public GetHlsPlaylistByChannelNumberHandler( - IChannelRepository channelRepository, - IPlayoutRepository playoutRepository, + IDbContextFactory dbContextFactory, IMemoryCache memoryCache) { - _channelRepository = channelRepository; - _playoutRepository = playoutRepository; + _dbContextFactory = dbContextFactory; _memoryCache = memoryCache; } - public Task> Handle( + public async Task> Handle( GetHlsPlaylistByChannelNumber request, - CancellationToken cancellationToken) => - ChannelMustExist(request) - .Map(v => v.ToEither()) - .BindT(channel => GetPlaylist(request, channel)); + CancellationToken cancellationToken) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + DateTimeOffset now = DateTimeOffset.Now; + Validation validation = await Validate(dbContext, request, now); + return await validation.Apply(parameters => GetPlaylist(dbContext, request, parameters, now)); + } - private async Task> GetPlaylist( + private Task GetPlaylist( + TvContext dbContext, GetHlsPlaylistByChannelNumber request, - Channel channel) + Parameters parameters, + DateTimeOffset now) { string mode = string.IsNullOrWhiteSpace(request.Mode) ? string.Empty : $"&mode={request.Mode}"; - DateTimeOffset now = DateTimeOffset.Now; - Option maybePlayoutItem = await _playoutRepository.GetPlayoutItem(channel.Id, now); - return maybePlayoutItem.Match>( - playoutItem => - { - long index = GetIndexForChannel(channel, playoutItem); - double timeRemaining = Math.Abs((playoutItem.FinishOffset - now).TotalSeconds); - return $@"#EXTM3U + long index = GetIndexForChannel(parameters.Channel, parameters.PlayoutItem); + double timeRemaining = Math.Abs((parameters.PlayoutItem.FinishOffset - now).TotalSeconds); + return $@"#EXTM3U #EXT-X-VERSION:3 #EXT-X-TARGETDURATION:10 #EXT-X-MEDIA-SEQUENCE:{index} #EXT-X-DISCONTINUITY #EXTINF:{timeRemaining:F2}, {request.Scheme}://{request.Host}/ffmpeg/stream/{request.ChannelNumber}?index={index}{mode} -"; - }, - () => - { - // TODO: playlist for error stream - Log.Logger.Error("Unable to locate playout item for m3u8"); - return BaseError.New($"Unable to locate playout item for channel {channel.Number}"); - }); +".AsTask(); } - private async Task> ChannelMustExist(GetHlsPlaylistByChannelNumber request) => - (await _channelRepository.GetByNumber(request.ChannelNumber)) - .ToValidation($"Channel number {request.ChannelNumber} does not exist."); + private Task> Validate( + TvContext dbContext, + GetHlsPlaylistByChannelNumber request, + DateTimeOffset now) => + ChannelMustExist(dbContext, request) + .BindT(channel => PlayoutItemMustExist(dbContext, channel, now)); + + private static Task> ChannelMustExist( + TvContext dbContext, + GetHlsPlaylistByChannelNumber request) => + dbContext.Channels + .SelectOneAsync(c => c.Number, c => c.Number == request.ChannelNumber) + .Map(o => o.ToValidation($"Channel number {request.ChannelNumber} does not exist.")); + + private static Task> PlayoutItemMustExist( + TvContext dbContext, + Channel channel, + DateTimeOffset now) => + dbContext.PlayoutItems + .ForChannelAndTime(channel.Id, now) + .MapT(playoutItem => new Parameters(channel, playoutItem)) + .Map(o => o.ToValidation($"Unable to locate playout item for channel {channel.Number}")); private long GetIndexForChannel(Channel channel, PlayoutItem playoutItem) { @@ -101,5 +111,7 @@ namespace ErsatzTV.Application.Streaming.Queries private record ChannelIndexKey(int ChannelId); private record ChannelIndexRecord(long StartTicks, long Index); + + private record Parameters(Channel Channel, PlayoutItem PlayoutItem); } } diff --git a/ErsatzTV.Application/Streaming/Queries/GetPlayoutItemProcessByChannelNumberHandler.cs b/ErsatzTV.Application/Streaming/Queries/GetPlayoutItemProcessByChannelNumberHandler.cs index 7febe17f3..6c1e023a8 100644 --- a/ErsatzTV.Application/Streaming/Queries/GetPlayoutItemProcessByChannelNumberHandler.cs +++ b/ErsatzTV.Application/Streaming/Queries/GetPlayoutItemProcessByChannelNumberHandler.cs @@ -1,5 +1,6 @@ using System; using System.Diagnostics; +using System.Linq; using System.Runtime.InteropServices; using System.Threading.Tasks; using ErsatzTV.Core; @@ -10,39 +11,35 @@ using ErsatzTV.Core.Interfaces.Emby; using ErsatzTV.Core.Interfaces.Jellyfin; using ErsatzTV.Core.Interfaces.Metadata; using ErsatzTV.Core.Interfaces.Plex; -using ErsatzTV.Core.Interfaces.Repositories; using ErsatzTV.Core.Interfaces.Runtime; +using ErsatzTV.Infrastructure.Data; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; +using Microsoft.EntityFrameworkCore; using static LanguageExt.Prelude; namespace ErsatzTV.Application.Streaming.Queries { - public class - GetPlayoutItemProcessByChannelNumberHandler : FFmpegProcessHandler + public class GetPlayoutItemProcessByChannelNumberHandler : + FFmpegProcessHandler { - private readonly IConfigElementRepository _configElementRepository; private readonly IEmbyPathReplacementService _embyPathReplacementService; private readonly FFmpegProcessService _ffmpegProcessService; private readonly IJellyfinPathReplacementService _jellyfinPathReplacementService; private readonly ILocalFileSystem _localFileSystem; - private readonly IPlayoutRepository _playoutRepository; private readonly IPlexPathReplacementService _plexPathReplacementService; private readonly IRuntimeInfo _runtimeInfo; public GetPlayoutItemProcessByChannelNumberHandler( - IChannelRepository channelRepository, - IConfigElementRepository configElementRepository, - IPlayoutRepository playoutRepository, + IDbContextFactory dbContextFactory, FFmpegProcessService ffmpegProcessService, ILocalFileSystem localFileSystem, IPlexPathReplacementService plexPathReplacementService, IJellyfinPathReplacementService jellyfinPathReplacementService, IEmbyPathReplacementService embyPathReplacementService, IRuntimeInfo runtimeInfo) - : base(channelRepository, configElementRepository) + : base(dbContextFactory) { - _configElementRepository = configElementRepository; - _playoutRepository = playoutRepository; _ffmpegProcessService = ffmpegProcessService; _localFileSystem = localFileSystem; _plexPathReplacementService = plexPathReplacementService; @@ -52,13 +49,32 @@ namespace ErsatzTV.Application.Streaming.Queries } protected override async Task> GetProcess( + TvContext dbContext, GetPlayoutItemProcessByChannelNumber _, Channel channel, string ffmpegPath) { DateTimeOffset now = DateTimeOffset.Now; - Either maybePlayoutItem = await _playoutRepository - .GetPlayoutItem(channel.Id, now) + Either maybePlayoutItem = await dbContext.PlayoutItems + .Include(i => i.MediaItem) + .ThenInclude(mi => (mi as Episode).MediaVersions) + .ThenInclude(mv => mv.MediaFiles) + .Include(i => i.MediaItem) + .ThenInclude(mi => (mi as Episode).MediaVersions) + .ThenInclude(mv => mv.Streams) + .Include(i => i.MediaItem) + .ThenInclude(mi => (mi as Movie).MediaVersions) + .ThenInclude(mv => mv.MediaFiles) + .Include(i => i.MediaItem) + .ThenInclude(mi => (mi as Movie).MediaVersions) + .ThenInclude(mv => mv.Streams) + .Include(i => i.MediaItem) + .ThenInclude(mi => (mi as MusicVideo).MediaVersions) + .ThenInclude(mv => mv.MediaFiles) + .Include(i => i.MediaItem) + .ThenInclude(mi => (mi as MusicVideo).MediaVersions) + .ThenInclude(mv => mv.Streams) + .ForChannelAndTime(channel.Id, now) .Map(o => o.ToEither(new UnableToLocatePlayoutItem())) .BindT(ValidatePlayoutItemPath); @@ -73,7 +89,7 @@ namespace ErsatzTV.Application.Streaming.Queries _ => throw new ArgumentOutOfRangeException(nameof(playoutItemWithPath)) }; - bool saveReports = !_runtimeInfo.IsOSPlatform(OSPlatform.Windows) && await _configElementRepository + bool saveReports = !_runtimeInfo.IsOSPlatform(OSPlatform.Windows) && await dbContext.ConfigElements .GetValue(ConfigElementKey.FFmpegSaveReports) .Map(result => result.IfNone(false)); @@ -95,8 +111,13 @@ namespace ErsatzTV.Application.Streaming.Queries Option maybeDuration = await Optional(channel.FFmpegProfile.Transcode) .Filter(transcode => transcode) .Match( - _ => _playoutRepository.GetNextItemStart(channel.Id, now) - .MapT(nextStart => nextStart - now), + _ => dbContext.PlayoutItems + .Filter(pi => pi.Playout.ChannelId == channel.Id) + .Filter(pi => pi.Start > now.UtcDateTime) + .OrderBy(pi => pi.Start) + .FirstOrDefaultAsync() + .Map(Optional) + .MapT(pi => pi.StartOffset - now), () => Option.None.AsTask()); switch (error) diff --git a/ErsatzTV.Application/Television/Mapper.cs b/ErsatzTV.Application/Television/Mapper.cs index 70df8ea80..053e2e0a7 100644 --- a/ErsatzTV.Application/Television/Mapper.cs +++ b/ErsatzTV.Application/Television/Mapper.cs @@ -57,19 +57,6 @@ namespace ErsatzTV.Application.Television season.Show.ShowMetadata.HeadOrNone().Map(m => GetFanArt(m, maybeJellyfin, maybeEmby)) .IfNone(string.Empty)); - internal static TelevisionEpisodeViewModel ProjectToViewModel(Episode episode) - { - Option maybeMetadata = episode.EpisodeMetadata.HeadOrNone(); - - return new TelevisionEpisodeViewModel( - episode.Season.ShowId, - episode.SeasonId, - maybeMetadata.Map(em => em.EpisodeNumber).IfNone(0), - maybeMetadata.Map(m => m.Title ?? string.Empty).IfNone(string.Empty), - maybeMetadata.Map(m => m.Plot ?? string.Empty).IfNone(string.Empty), - maybeMetadata.Map(m => GetThumbnail(m, None, None)).IfNone(string.Empty)); - } - private static string GetPoster( Metadata metadata, Option maybeJellyfin, @@ -82,12 +69,6 @@ namespace ErsatzTV.Application.Television Option maybeEmby) => GetArtwork(metadata, ArtworkKind.FanArt, maybeJellyfin, maybeEmby); - private static string GetThumbnail( - Metadata metadata, - Option maybeJellyfin, - Option maybeEmby) => - GetArtwork(metadata, ArtworkKind.Thumbnail, maybeJellyfin, maybeEmby); - private static string GetArtwork( Metadata metadata, ArtworkKind artworkKind, diff --git a/ErsatzTV.Application/Television/Queries/GetTelevisionEpisodeById.cs b/ErsatzTV.Application/Television/Queries/GetTelevisionEpisodeById.cs deleted file mode 100644 index 2e6cc0330..000000000 --- a/ErsatzTV.Application/Television/Queries/GetTelevisionEpisodeById.cs +++ /dev/null @@ -1,7 +0,0 @@ -using LanguageExt; -using MediatR; - -namespace ErsatzTV.Application.Television.Queries -{ - public record GetTelevisionEpisodeById(int EpisodeId) : IRequest>; -} diff --git a/ErsatzTV.Application/Television/Queries/GetTelevisionEpisodeByIdHandler.cs b/ErsatzTV.Application/Television/Queries/GetTelevisionEpisodeByIdHandler.cs deleted file mode 100644 index 69a0fc33a..000000000 --- a/ErsatzTV.Application/Television/Queries/GetTelevisionEpisodeByIdHandler.cs +++ /dev/null @@ -1,24 +0,0 @@ -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 - GetTelevisionEpisodeByIdHandler : IRequestHandler> - { - private readonly ITelevisionRepository _televisionRepository; - - public GetTelevisionEpisodeByIdHandler(ITelevisionRepository televisionRepository) => - _televisionRepository = televisionRepository; - - public Task> Handle( - GetTelevisionEpisodeById request, - CancellationToken cancellationToken) => - _televisionRepository.GetEpisode(request.EpisodeId) - .MapT(ProjectToViewModel); - } -} diff --git a/ErsatzTV.Application/Television/TelevisionEpisodeViewModel.cs b/ErsatzTV.Application/Television/TelevisionEpisodeViewModel.cs deleted file mode 100644 index 937a943fa..000000000 --- a/ErsatzTV.Application/Television/TelevisionEpisodeViewModel.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ErsatzTV.Application.Television -{ - public record TelevisionEpisodeViewModel( - int ShowId, - int SeasonId, - int Episode, - string Title, - string Plot, - string Poster); -} diff --git a/ErsatzTV.Core.Tests/Fakes/FakeMediaCollectionRepository.cs b/ErsatzTV.Core.Tests/Fakes/FakeMediaCollectionRepository.cs index da5dd441c..aeb664311 100644 --- a/ErsatzTV.Core.Tests/Fakes/FakeMediaCollectionRepository.cs +++ b/ErsatzTV.Core.Tests/Fakes/FakeMediaCollectionRepository.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; using ErsatzTV.Core.Domain; using ErsatzTV.Core.Interfaces.Repositories; using LanguageExt; -using static LanguageExt.Prelude; namespace ErsatzTV.Core.Tests.Fakes { @@ -15,25 +14,10 @@ namespace ErsatzTV.Core.Tests.Fakes public FakeMediaCollectionRepository(Map> data) => _data = data; - public Task Add(Collection collection) => throw new NotSupportedException(); - public Task AddMediaItem(int collectionId, int mediaItemId) => throw new NotSupportedException(); - public Task AddMediaItems(int collectionId, List mediaItemIds) => throw new NotSupportedException(); - public Task> Get(int id) => throw new NotSupportedException(); - public Task> GetCollectionWithItems(int id) => throw new NotSupportedException(); - public Task> GetCollectionWithItemsUntracked(int id) => throw new NotSupportedException(); - public Task> GetCollectionWithCollectionItemsUntracked(int id) => throw new NotSupportedException(); - public Task> GetAll() => throw new NotSupportedException(); - public Task CountAllCollections() => throw new NotSupportedException(); - - public Task> GetPagedCollections(int pageNumber, int pageSize) => - throw new NotSupportedException(); - - public Task>> GetItems(int id) => Some(_data[id].ToList()).AsTask(); - Task IMediaCollectionRepository.Update(Collection collection) => throw new NotSupportedException(); - public Task Delete(int collectionId) => throw new NotSupportedException(); + public Task> GetItems(int id) => _data[id].ToList().AsTask(); public Task> PlayoutIdsUsingCollection(int collectionId) => throw new NotSupportedException(); public Task IsCustomPlaybackOrder(int collectionId) => false.AsTask(); } diff --git a/ErsatzTV.Core/FFmpeg/FFmpegLocator.cs b/ErsatzTV.Core/FFmpeg/FFmpegLocator.cs index d0102b166..b630e8405 100644 --- a/ErsatzTV.Core/FFmpeg/FFmpegLocator.cs +++ b/ErsatzTV.Core/FFmpeg/FFmpegLocator.cs @@ -43,7 +43,7 @@ namespace ErsatzTV.Core.FFmpeg return await maybePath.MatchAsync( async path => { - await _configElementRepository.Add(new ConfigElement { Key = key.Key, Value = path }); + await _configElementRepository.Upsert(key, path); return Some(path); }, () => None); diff --git a/ErsatzTV.Core/Interfaces/Metadata/ILocalFileSystem.cs b/ErsatzTV.Core/Interfaces/Metadata/ILocalFileSystem.cs index 86b070dc1..c636ee70d 100644 --- a/ErsatzTV.Core/Interfaces/Metadata/ILocalFileSystem.cs +++ b/ErsatzTV.Core/Interfaces/Metadata/ILocalFileSystem.cs @@ -14,7 +14,6 @@ namespace ErsatzTV.Core.Interfaces.Metadata IEnumerable ListSubdirectories(string folder); IEnumerable ListFiles(string folder); bool FileExists(string path); - Task ReadAllBytes(string path); Task> CopyFile(string source, string destination); } } diff --git a/ErsatzTV.Core/Interfaces/Repositories/IChannelRepository.cs b/ErsatzTV.Core/Interfaces/Repositories/IChannelRepository.cs index d7bea7876..d7338d4a8 100644 --- a/ErsatzTV.Core/Interfaces/Repositories/IChannelRepository.cs +++ b/ErsatzTV.Core/Interfaces/Repositories/IChannelRepository.cs @@ -7,14 +7,12 @@ namespace ErsatzTV.Core.Interfaces.Repositories { public interface IChannelRepository { - Task Add(Channel channel); Task> Get(int id); Task> GetByNumber(string number); Task> GetAll(); Task> GetAllForGuide(); Task Update(Channel channel); Task Delete(int channelId); - Task CountPlayouts(int channelId); Task RemoveWatermark(Channel channel); } } diff --git a/ErsatzTV.Core/Interfaces/Repositories/IConfigElementRepository.cs b/ErsatzTV.Core/Interfaces/Repositories/IConfigElementRepository.cs index bd83fc4e1..2a1a4faf3 100644 --- a/ErsatzTV.Core/Interfaces/Repositories/IConfigElementRepository.cs +++ b/ErsatzTV.Core/Interfaces/Repositories/IConfigElementRepository.cs @@ -6,10 +6,9 @@ namespace ErsatzTV.Core.Interfaces.Repositories { public interface IConfigElementRepository { - Task Add(ConfigElement configElement); + Task Upsert(ConfigElementKey configElementKey, T value); Task> Get(ConfigElementKey key); Task> GetValue(ConfigElementKey key); - Task Update(ConfigElement configElement); Task Delete(ConfigElement configElement); } } diff --git a/ErsatzTV.Core/Interfaces/Repositories/IFFmpegProfileRepository.cs b/ErsatzTV.Core/Interfaces/Repositories/IFFmpegProfileRepository.cs index b78cfe708..bc378ff85 100644 --- a/ErsatzTV.Core/Interfaces/Repositories/IFFmpegProfileRepository.cs +++ b/ErsatzTV.Core/Interfaces/Repositories/IFFmpegProfileRepository.cs @@ -1,17 +1,10 @@ -using System.Collections.Generic; -using System.Threading.Tasks; +using System.Threading.Tasks; using ErsatzTV.Core.Domain; -using LanguageExt; namespace ErsatzTV.Core.Interfaces.Repositories { public interface IFFmpegProfileRepository { - Task Add(FFmpegProfile ffmpegProfile); - Task> Get(int id); - Task> GetAll(); - Task Update(FFmpegProfile ffmpegProfile); - Task Delete(int ffmpegProfileId); Task Copy(int ffmpegProfileId, string name); } } diff --git a/ErsatzTV.Core/Interfaces/Repositories/IMediaCollectionRepository.cs b/ErsatzTV.Core/Interfaces/Repositories/IMediaCollectionRepository.cs index bca9db005..d91406fe5 100644 --- a/ErsatzTV.Core/Interfaces/Repositories/IMediaCollectionRepository.cs +++ b/ErsatzTV.Core/Interfaces/Repositories/IMediaCollectionRepository.cs @@ -7,19 +7,8 @@ namespace ErsatzTV.Core.Interfaces.Repositories { public interface IMediaCollectionRepository { - Task Add(Collection collection); - Task AddMediaItem(int collectionId, int mediaItemId); - Task AddMediaItems(int collectionId, List mediaItemIds); - Task> Get(int id); - Task> GetCollectionWithItems(int id); - Task> GetCollectionWithItemsUntracked(int id); Task> GetCollectionWithCollectionItemsUntracked(int id); - Task> GetAll(); - Task CountAllCollections(); - Task> GetPagedCollections(int pageNumber, int pageSize); - Task>> GetItems(int id); - Task Update(Collection collection); - Task Delete(int collectionId); + Task> GetItems(int id); Task> PlayoutIdsUsingCollection(int collectionId); Task IsCustomPlaybackOrder(int collectionId); } diff --git a/ErsatzTV.Core/Interfaces/Repositories/IMediaItemRepository.cs b/ErsatzTV.Core/Interfaces/Repositories/IMediaItemRepository.cs index 42741d256..7f71301cb 100644 --- a/ErsatzTV.Core/Interfaces/Repositories/IMediaItemRepository.cs +++ b/ErsatzTV.Core/Interfaces/Repositories/IMediaItemRepository.cs @@ -1,15 +1,10 @@ using System.Collections.Generic; using System.Threading.Tasks; -using ErsatzTV.Core.Domain; -using LanguageExt; namespace ErsatzTV.Core.Interfaces.Repositories { public interface IMediaItemRepository { - Task> Get(int id); - Task> GetAll(); - Task Update(MediaItem mediaItem); Task> GetAllLanguageCodes(); } } diff --git a/ErsatzTV.Core/Interfaces/Repositories/IMediaSourceRepository.cs b/ErsatzTV.Core/Interfaces/Repositories/IMediaSourceRepository.cs index ca4e52925..27a57f3b4 100644 --- a/ErsatzTV.Core/Interfaces/Repositories/IMediaSourceRepository.cs +++ b/ErsatzTV.Core/Interfaces/Repositories/IMediaSourceRepository.cs @@ -7,19 +7,14 @@ namespace ErsatzTV.Core.Interfaces.Repositories { public interface IMediaSourceRepository { - Task Add(LocalMediaSource localMediaSource); Task Add(PlexMediaSource plexMediaSource); - Task> GetAll(); Task> GetAllPlex(); Task> GetPlexLibraries(int plexMediaSourceId); Task> GetPlexPathReplacements(int plexMediaSourceId); Task> GetPlexLibrary(int plexLibraryId); - Task> Get(int id); Task> GetPlex(int id); Task> GetPlexByLibraryId(int plexLibraryId); Task> GetPlexPathReplacementsByLibraryId(int plexLibraryPathId); - Task CountMediaItems(int id); - Task Update(LocalMediaSource localMediaSource); Task Update( PlexMediaSource plexMediaSource, @@ -48,8 +43,6 @@ namespace ErsatzTV.Core.Interfaces.Repositories List toUpdate, List toDelete); - Task Update(PlexLibrary plexMediaSourceLibrary); - Task Delete(int mediaSourceId); Task> DeleteAllPlex(); Task> DeletePlex(PlexMediaSource plexMediaSource); Task> DisablePlexLibrarySync(List libraryIds); diff --git a/ErsatzTV.Core/Interfaces/Repositories/IMovieRepository.cs b/ErsatzTV.Core/Interfaces/Repositories/IMovieRepository.cs index 2597de5e8..a6a27e584 100644 --- a/ErsatzTV.Core/Interfaces/Repositories/IMovieRepository.cs +++ b/ErsatzTV.Core/Interfaces/Repositories/IMovieRepository.cs @@ -14,8 +14,6 @@ namespace ErsatzTV.Core.Interfaces.Repositories Task> GetMovie(int movieId); Task>> GetOrAdd(LibraryPath libraryPath, string path); Task>> GetOrAdd(PlexLibrary library, PlexMovie item); - Task GetMovieCount(); - Task> GetPagedMovies(int pageNumber, int pageSize); Task> GetMoviesForCards(List ids); Task> FindMoviePaths(LibraryPath libraryPath); Task> DeleteByPath(LibraryPath libraryPath, string path); diff --git a/ErsatzTV.Core/Interfaces/Repositories/IMusicVideoRepository.cs b/ErsatzTV.Core/Interfaces/Repositories/IMusicVideoRepository.cs index 0052bd4a6..918bfc73b 100644 --- a/ErsatzTV.Core/Interfaces/Repositories/IMusicVideoRepository.cs +++ b/ErsatzTV.Core/Interfaces/Repositories/IMusicVideoRepository.cs @@ -19,7 +19,6 @@ namespace ErsatzTV.Core.Interfaces.Repositories Task AddTag(MusicVideoMetadata metadata, Tag tag); Task AddStudio(MusicVideoMetadata metadata, Studio studio); Task> GetMusicVideosForCards(List ids); - Task> GetMusicVideo(int musicVideoId); Task> FindOrphanPaths(LibraryPath libraryPath); Task GetMusicVideoCount(int artistId); Task> GetPagedMusicVideos(int artistId, int pageNumber, int pageSize); diff --git a/ErsatzTV.Core/Interfaces/Repositories/IPlayoutRepository.cs b/ErsatzTV.Core/Interfaces/Repositories/IPlayoutRepository.cs deleted file mode 100644 index 98985e99d..000000000 --- a/ErsatzTV.Core/Interfaces/Repositories/IPlayoutRepository.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using ErsatzTV.Core.Domain; -using LanguageExt; - -namespace ErsatzTV.Core.Interfaces.Repositories -{ - public interface IPlayoutRepository - { - Task Add(Playout playout); - Task> Get(int id); - Task> GetFull(int id); - Task> GetPlayoutItem(int channelId, DateTimeOffset now); - Task> GetNextItemStart(int channelId, DateTimeOffset now); - Task> GetPlayoutItems(int playoutId); - Task> GetAll(); - Task Update(Playout playout); - Task Delete(int playoutId); - } -} diff --git a/ErsatzTV.Core/Interfaces/Repositories/IProgramScheduleRepository.cs b/ErsatzTV.Core/Interfaces/Repositories/IProgramScheduleRepository.cs deleted file mode 100644 index bb2bf429e..000000000 --- a/ErsatzTV.Core/Interfaces/Repositories/IProgramScheduleRepository.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using ErsatzTV.Core.Domain; -using LanguageExt; - -namespace ErsatzTV.Core.Interfaces.Repositories -{ - public interface IProgramScheduleRepository - { - Task Add(ProgramSchedule programSchedule); - Task> Get(int id); - Task> GetWithPlayouts(int id); - Task> GetAll(); - Task Update(ProgramSchedule programSchedule); - Task Delete(int programScheduleId); - Task>> GetItems(int programScheduleId); - } -} diff --git a/ErsatzTV.Core/Interfaces/Repositories/IResolutionRepository.cs b/ErsatzTV.Core/Interfaces/Repositories/IResolutionRepository.cs deleted file mode 100644 index fc0abc191..000000000 --- a/ErsatzTV.Core/Interfaces/Repositories/IResolutionRepository.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using ErsatzTV.Core.Domain; -using LanguageExt; - -namespace ErsatzTV.Core.Interfaces.Repositories -{ - public interface IResolutionRepository - { - Task> Get(int id); - Task> GetAll(); - } -} diff --git a/ErsatzTV.Core/Interfaces/Repositories/ITelevisionRepository.cs b/ErsatzTV.Core/Interfaces/Repositories/ITelevisionRepository.cs index 5128e1cff..14ced0705 100644 --- a/ErsatzTV.Core/Interfaces/Repositories/ITelevisionRepository.cs +++ b/ErsatzTV.Core/Interfaces/Repositories/ITelevisionRepository.cs @@ -20,7 +20,6 @@ namespace ErsatzTV.Core.Interfaces.Repositories Task GetSeasonCount(int showId); Task> GetPagedSeasons(int televisionShowId, int pageNumber, int pageSize); Task> GetSeasonItems(int seasonId); - Task> GetEpisode(int episodeId); Task GetEpisodeCount(int seasonId); Task> GetPagedEpisodes(int seasonId, int pageNumber, int pageSize); Task> GetShowByMetadata(int libraryPathId, ShowMetadata metadata); diff --git a/ErsatzTV.Core/LanguageExtensions.cs b/ErsatzTV.Core/LanguageExtensions.cs index dfd812b6d..99b0d07f6 100644 --- a/ErsatzTV.Core/LanguageExtensions.cs +++ b/ErsatzTV.Core/LanguageExtensions.cs @@ -1,6 +1,8 @@ -using System.Diagnostics.CodeAnalysis; +using System; +using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; using LanguageExt; +using static LanguageExt.Prelude; using Microsoft.Extensions.Logging; namespace ErsatzTV.Core @@ -16,6 +18,13 @@ namespace ErsatzTV.Core .MapLeft(errors => errors.Join()) .MapAsync, TR>(e => e); + public static Task> Apply( + this Validation validation, + Func> task) => + validation.Match>>( + async t => await task(t), + error => Task.FromResult(Left(error.Join()))); + public static Task LogFailure( this TryAsync tryAsync, T defaultValue, diff --git a/ErsatzTV.Core/Metadata/LocalFileSystem.cs b/ErsatzTV.Core/Metadata/LocalFileSystem.cs index 95d8fbd6e..d0183f79c 100644 --- a/ErsatzTV.Core/Metadata/LocalFileSystem.cs +++ b/ErsatzTV.Core/Metadata/LocalFileSystem.cs @@ -34,7 +34,6 @@ namespace ErsatzTV.Core.Metadata Try(Directory.EnumerateFiles(folder, "*", SearchOption.TopDirectoryOnly)).IfFail(new List()); public bool FileExists(string path) => File.Exists(path); - public Task ReadAllBytes(string path) => File.ReadAllBytesAsync(path); public async Task> CopyFile(string source, string destination) { diff --git a/ErsatzTV.Core/Scheduling/PlayoutBuilder.cs b/ErsatzTV.Core/Scheduling/PlayoutBuilder.cs index b6c7c7d79..e513273c4 100644 --- a/ErsatzTV.Core/Scheduling/PlayoutBuilder.cs +++ b/ErsatzTV.Core/Scheduling/PlayoutBuilder.cs @@ -58,9 +58,9 @@ namespace ErsatzTV.Core.Scheduling switch (collectionKey.CollectionType) { case ProgramScheduleItemCollectionType.Collection: - Option> maybeItems = + List collectionItems = await _mediaCollectionRepository.GetItems(collectionKey.CollectionId ?? 0); - return Tuple(collectionKey, await maybeItems.IfNoneAsync(new List())); + return Tuple(collectionKey, collectionItems); case ProgramScheduleItemCollectionType.TelevisionShow: List showItems = await _televisionRepository.GetShowItems(collectionKey.MediaItemId ?? 0); diff --git a/ErsatzTV.Infrastructure/Data/Repositories/ChannelRepository.cs b/ErsatzTV.Infrastructure/Data/Repositories/ChannelRepository.cs index b3c91488f..bc7814ea2 100644 --- a/ErsatzTV.Infrastructure/Data/Repositories/ChannelRepository.cs +++ b/ErsatzTV.Infrastructure/Data/Repositories/ChannelRepository.cs @@ -22,14 +22,6 @@ namespace ErsatzTV.Infrastructure.Data.Repositories _dbConnection = dbConnection; } - public async Task Add(Channel channel) - { - await using TvContext dbContext = _dbContextFactory.CreateDbContext(); - await dbContext.Channels.AddAsync(channel); - await dbContext.SaveChangesAsync(); - return channel; - } - public async Task> Get(int id) { await using TvContext dbContext = _dbContextFactory.CreateDbContext(); @@ -124,11 +116,6 @@ namespace ErsatzTV.Infrastructure.Data.Repositories await dbContext.SaveChangesAsync(); } - public Task CountPlayouts(int channelId) => - _dbConnection.QuerySingleAsync( - @"SELECT COUNT(*) FROM Playout WHERE ChannelId = @ChannelId", - new { ChannelId = channelId }); - public async Task RemoveWatermark(Channel channel) { if (channel.Watermark != null) diff --git a/ErsatzTV.Infrastructure/Data/Repositories/ConfigElementRepository.cs b/ErsatzTV.Infrastructure/Data/Repositories/ConfigElementRepository.cs index c57693b39..0d5b08525 100644 --- a/ErsatzTV.Infrastructure/Data/Repositories/ConfigElementRepository.cs +++ b/ErsatzTV.Infrastructure/Data/Repositories/ConfigElementRepository.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Threading.Tasks; using ErsatzTV.Core.Domain; using ErsatzTV.Core.Interfaces.Repositories; +using ErsatzTV.Infrastructure.Extensions; using LanguageExt; using Microsoft.EntityFrameworkCore; using static LanguageExt.Prelude; @@ -11,36 +12,56 @@ namespace ErsatzTV.Infrastructure.Data.Repositories { public class ConfigElementRepository : IConfigElementRepository { - private readonly TvContext _dbContext; + private readonly IDbContextFactory _dbContextFactory; - public ConfigElementRepository(TvContext dbContext) => _dbContext = dbContext; + public ConfigElementRepository(IDbContextFactory dbContextFactory) => + _dbContextFactory = dbContextFactory; - public async Task Add(ConfigElement configElement) + public async Task Upsert(ConfigElementKey configElementKey, T value) { - await _dbContext.ConfigElements.AddAsync(configElement); - await _dbContext.SaveChangesAsync(); - return configElement; + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + + Option maybeElement = await dbContext.ConfigElements + .SelectOneAsync(c => c.Key, c => c.Key == configElementKey.Key); + + await maybeElement.Match( + async element => + { + element.Value = value.ToString(); + await dbContext.SaveChangesAsync(); + }, + async () => + { + var configElement = new ConfigElement + { + Key = configElementKey.Key, + Value = value.ToString() + }; + + await dbContext.ConfigElements.AddAsync(configElement); + await dbContext.SaveChangesAsync(); + }); + + return Unit.Default; } - public Task> Get(ConfigElementKey key) => - _dbContext.ConfigElements + public async Task> Get(ConfigElementKey key) + { + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + return await dbContext.ConfigElements .OrderBy(ce => ce.Key) .SingleOrDefaultAsync(ce => ce.Key == key.Key) .Map(Optional); + } public Task> GetValue(ConfigElementKey key) => Get(key).MapT(ce => (T) Convert.ChangeType(ce.Value, typeof(T))); - public Task Update(ConfigElement configElement) - { - _dbContext.ConfigElements.Update(configElement); - return _dbContext.SaveChangesAsync(); - } - - public Task Delete(ConfigElement configElement) + public async Task Delete(ConfigElement configElement) { - _dbContext.ConfigElements.Remove(configElement); - return _dbContext.SaveChangesAsync(); + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + dbContext.ConfigElements.Remove(configElement); + await dbContext.SaveChangesAsync(); } } } diff --git a/ErsatzTV.Infrastructure/Data/Repositories/FFmpegProfileRepository.cs b/ErsatzTV.Infrastructure/Data/Repositories/FFmpegProfileRepository.cs index 7ff547cff..1bedf0eab 100644 --- a/ErsatzTV.Infrastructure/Data/Repositories/FFmpegProfileRepository.cs +++ b/ErsatzTV.Infrastructure/Data/Repositories/FFmpegProfileRepository.cs @@ -1,9 +1,6 @@ -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using System.Threading.Tasks; using ErsatzTV.Core.Domain; using ErsatzTV.Core.Interfaces.Repositories; -using LanguageExt; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.ChangeTracking; @@ -11,45 +8,10 @@ namespace ErsatzTV.Infrastructure.Data.Repositories { public class FFmpegProfileRepository : IFFmpegProfileRepository { - private readonly TvContext _dbContext; private readonly IDbContextFactory _dbContextFactory; - public FFmpegProfileRepository(IDbContextFactory dbContextFactory, TvContext dbContext) - { + public FFmpegProfileRepository(IDbContextFactory dbContextFactory) => _dbContextFactory = dbContextFactory; - _dbContext = dbContext; - } - - public async Task Add(FFmpegProfile ffmpegProfile) - { - await _dbContext.FFmpegProfiles.AddAsync(ffmpegProfile); - await _dbContext.SaveChangesAsync(); - return ffmpegProfile; - } - - public async Task> Get(int id) => - await _dbContext.FFmpegProfiles - .Include(p => p.Resolution) - .OrderBy(p => p.Id) - .SingleOrDefaultAsync(p => p.Id == id); - - public Task> GetAll() => - _dbContext.FFmpegProfiles - .Include(p => p.Resolution) - .ToListAsync(); - - public Task Update(FFmpegProfile ffmpegProfile) - { - _dbContext.FFmpegProfiles.Update(ffmpegProfile); - return _dbContext.SaveChangesAsync(); - } - - public async Task Delete(int ffmpegProfileId) - { - FFmpegProfile ffmpegProfile = await _dbContext.FFmpegProfiles.FindAsync(ffmpegProfileId); - _dbContext.FFmpegProfiles.Remove(ffmpegProfile); - await _dbContext.SaveChangesAsync(); - } public async Task Copy(int ffmpegProfileId, string name) { diff --git a/ErsatzTV.Infrastructure/Data/Repositories/MediaCollectionRepository.cs b/ErsatzTV.Infrastructure/Data/Repositories/MediaCollectionRepository.cs index 63850a53c..d37daf1ac 100644 --- a/ErsatzTV.Infrastructure/Data/Repositories/MediaCollectionRepository.cs +++ b/ErsatzTV.Infrastructure/Data/Repositories/MediaCollectionRepository.cs @@ -14,203 +14,40 @@ namespace ErsatzTV.Infrastructure.Data.Repositories public class MediaCollectionRepository : IMediaCollectionRepository { private readonly IDbConnection _dbConnection; - private readonly TvContext _dbContext; private readonly IDbContextFactory _dbContextFactory; public MediaCollectionRepository( - TvContext dbContext, IDbContextFactory dbContextFactory, IDbConnection dbConnection) { - _dbContext = dbContext; _dbContextFactory = dbContextFactory; _dbConnection = dbConnection; } - public async Task Add(Collection collection) + public async Task> GetCollectionWithCollectionItemsUntracked(int id) { - await _dbContext.Collections.AddAsync(collection); - await _dbContext.SaveChangesAsync(); - return collection; - } - - public async Task AddMediaItem(int collectionId, int mediaItemId) - { - var modified = false; - - Option maybeCollection = await _dbContext.Collections - .Include(c => c.MediaItems) - .OrderBy(c => c.Id) - .SingleOrDefaultAsync(c => c.Id == collectionId) - .Map(Optional); - - await maybeCollection.IfSomeAsync( - async collection => - { - if (collection.MediaItems.All(i => i.Id != mediaItemId)) - { - Option maybeMediaItem = await _dbContext.MediaItems - .OrderBy(i => i.Id) - .SingleOrDefaultAsync(i => i.Id == mediaItemId) - .Map(Optional); - - await maybeMediaItem.IfSomeAsync( - async mediaItem => - { - collection.MediaItems.Add(mediaItem); - modified = await _dbContext.SaveChangesAsync() > 0; - }); - } - }); - - return modified; - } - - public async Task AddMediaItems(int collectionId, List mediaItemIds) - { - var modified = false; - - Option maybeCollection = await _dbContext.Collections - .Include(c => c.MediaItems) - .OrderBy(c => c.Id) - .SingleOrDefaultAsync(c => c.Id == collectionId) - .Map(Optional); - - await maybeCollection.IfSomeAsync( - async collection => - { - var toAdd = mediaItemIds.Filter(i => collection.MediaItems.All(i2 => i2.Id != i)).ToList(); - if (toAdd.Any()) - { - List items = await _dbContext.MediaItems - .Filter(mi => toAdd.Contains(mi.Id)) - .ToListAsync(); - - collection.MediaItems.AddRange(items); - modified = await _dbContext.SaveChangesAsync() > 0; - } - }); - - return modified; - } - - public Task> Get(int id) => - _dbContext.Collections - .Include(c => c.CollectionItems) - .OrderBy(c => c.Id) - .SingleOrDefaultAsync(c => c.Id == id) - .Map(Optional); - - public Task> GetCollectionWithItems(int id) => - _dbContext.Collections - .Include(c => c.MediaItems) - .ThenInclude(i => i.LibraryPath) - .Include(c => c.MediaItems) - .ThenInclude(i => (i as Movie).MovieMetadata) - .Include(c => c.MediaItems) - .ThenInclude(i => (i as MusicVideo).MusicVideoMetadata) - .Include(c => c.MediaItems) - .ThenInclude(i => (i as Show).ShowMetadata) - .Include(c => c.MediaItems) - .ThenInclude(i => (i as Season).Show) - .ThenInclude(s => s.ShowMetadata) - .Include(c => c.MediaItems) - .ThenInclude(i => (i as Episode).EpisodeMetadata) - .Include(c => c.MediaItems) - .ThenInclude(i => (i as Episode).Season) - .ThenInclude(s => s.Show) - .ThenInclude(s => s.ShowMetadata) - .OrderBy(c => c.Id) - .SingleOrDefaultAsync(c => c.Id == id) - .Map(Optional); - - public Task> GetCollectionWithItemsUntracked(int id) => - _dbContext.Collections - .AsNoTracking() - .Include(c => c.CollectionItems) - .Include(c => c.MediaItems) - .ThenInclude(i => i.LibraryPath) - .Include(c => c.MediaItems) - .ThenInclude(i => (i as Movie).MovieMetadata) - .ThenInclude(mm => mm.Artwork) - .Include(c => c.MediaItems) - .ThenInclude(i => (i as Artist).ArtistMetadata) - .ThenInclude(mvm => mvm.Artwork) - .Include(c => c.MediaItems) - .ThenInclude(i => (i as MusicVideo).MusicVideoMetadata) - .ThenInclude(mvm => mvm.Artwork) - .Include(c => c.MediaItems) - .ThenInclude(i => (i as MusicVideo).Artist) - .ThenInclude(a => a.ArtistMetadata) - .Include(c => c.MediaItems) - .ThenInclude(i => (i as Show).ShowMetadata) - .ThenInclude(sm => sm.Artwork) - .Include(c => c.MediaItems) - .ThenInclude(i => (i as Season).SeasonMetadata) - .ThenInclude(sm => sm.Artwork) - .Include(c => c.MediaItems) - .ThenInclude(i => (i as Season).Show) - .ThenInclude(s => s.ShowMetadata) - .Include(c => c.MediaItems) - .ThenInclude(i => (i as Episode).EpisodeMetadata) - .ThenInclude(em => em.Artwork) - .Include(c => c.MediaItems) - .ThenInclude(i => (i as Episode).EpisodeMetadata) - .ThenInclude(em => em.Directors) - .Include(c => c.MediaItems) - .ThenInclude(i => (i as Episode).EpisodeMetadata) - .ThenInclude(em => em.Writers) - .Include(c => c.MediaItems) - .ThenInclude(i => (i as Episode).Season) - .ThenInclude(s => s.Show) - .ThenInclude(s => s.ShowMetadata) - .Include(c => c.MediaItems) - .ThenInclude(i => (i as Episode).Season) - .ThenInclude(s => s.SeasonMetadata) - .OrderBy(c => c.Id) - .SingleOrDefaultAsync(c => c.Id == id) - .Map(Optional); - - public Task> GetCollectionWithCollectionItemsUntracked(int id) => - _dbContext.Collections + await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + return await dbContext.Collections .Include(c => c.CollectionItems) .OrderBy(c => c.Id) .SingleOrDefaultAsync(c => c.Id == id) .Map(Optional); + } - public Task> GetAll() => - _dbContext.Collections.ToListAsync(); - - public Task CountAllCollections() => - _dbConnection.QuerySingleAsync(@"SELECT COUNT (*) FROM Collection"); - - public async Task> GetPagedCollections(int pageNumber, int pageSize) + public async Task> GetItems(int collectionId) { await using TvContext dbContext = _dbContextFactory.CreateDbContext(); - return await dbContext.Collections.FromSqlRaw( - @"SELECT * FROM Collection - ORDER BY Name - LIMIT {0} OFFSET {1}", - pageSize, - pageNumber * pageSize) - .AsNoTracking() - .ToListAsync(); - } - public Task>> GetItems(int id) => - Get(id).MapT(GetItemsForCollection).Bind(x => x.Sequence()); + var result = new List(); - public Task Update(Collection collection) - { - _dbContext.Collections.Update(collection); - return _dbContext.SaveChangesAsync().Map(result => result > 0); - } + result.AddRange(await GetMovieItems(dbContext, collectionId)); + result.AddRange(await GetShowItems(dbContext, collectionId)); + result.AddRange(await GetSeasonItems(dbContext, collectionId)); + result.AddRange(await GetEpisodeItems(dbContext, collectionId)); + result.AddRange(await GetArtistItems(dbContext, collectionId)); + result.AddRange(await GetMusicVideoItems(dbContext, collectionId)); - public async Task Delete(int collectionId) - { - Collection mediaCollection = await _dbContext.Collections.FindAsync(collectionId); - _dbContext.Collections.Remove(mediaCollection); - await _dbContext.SaveChangesAsync(); + return result.Distinct().ToList(); } public Task> PlayoutIdsUsingCollection(int collectionId) => @@ -228,45 +65,31 @@ namespace ErsatzTV.Infrastructure.Data.Repositories @"SELECT IFNULL(MIN(UseCustomPlaybackOrder), 0) FROM Collection WHERE Id = @CollectionId", new { CollectionId = collectionId }); - private async Task> GetItemsForCollection(Collection collection) - { - var result = new List(); - - result.AddRange(await GetMovieItems(collection)); - result.AddRange(await GetShowItems(collection)); - result.AddRange(await GetSeasonItems(collection)); - result.AddRange(await GetEpisodeItems(collection)); - result.AddRange(await GetArtistItems(collection)); - result.AddRange(await GetMusicVideoItems(collection)); - - return result.Distinct().ToList(); - } - - private async Task> GetMovieItems(Collection collection) + private async Task> GetMovieItems(TvContext dbContext, int collectionId) { IEnumerable ids = await _dbConnection.QueryAsync( @"SELECT m.Id FROM CollectionItem ci INNER JOIN Movie m ON m.Id = ci.MediaItemId WHERE ci.CollectionId = @CollectionId", - new { CollectionId = collection.Id }); + new { CollectionId = collectionId }); - return await _dbContext.Movies + return await dbContext.Movies .Include(m => m.MovieMetadata) .Include(m => m.MediaVersions) .Filter(m => ids.Contains(m.Id)) .ToListAsync(); } - private async Task> GetArtistItems(Collection collection) + private async Task> GetArtistItems(TvContext dbContext, int collectionId) { IEnumerable ids = await _dbConnection.QueryAsync( @"SELECT MusicVideo.Id FROM CollectionItem ci INNER JOIN Artist on Artist.Id = ci.MediaItemId INNER JOIN MusicVideo on Artist.Id = MusicVideo.ArtistId WHERE ci.CollectionId = @CollectionId", - new { CollectionId = collection.Id }); + new { CollectionId = collectionId }); - return await _dbContext.MusicVideos + return await dbContext.MusicVideos .Include(m => m.Artist) .ThenInclude(a => a.ArtistMetadata) .Include(m => m.MusicVideoMetadata) @@ -276,15 +99,15 @@ namespace ErsatzTV.Infrastructure.Data.Repositories } - private async Task> GetMusicVideoItems(Collection collection) + private async Task> GetMusicVideoItems(TvContext dbContext, int collectionId) { IEnumerable ids = await _dbConnection.QueryAsync( @"SELECT m.Id FROM CollectionItem ci INNER JOIN MusicVideo m ON m.Id = ci.MediaItemId WHERE ci.CollectionId = @CollectionId", - new { CollectionId = collection.Id }); + new { CollectionId = collectionId }); - return await _dbContext.MusicVideos + return await dbContext.MusicVideos .Include(m => m.Artist) .ThenInclude(a => a.ArtistMetadata) .Include(m => m.MusicVideoMetadata) @@ -293,7 +116,7 @@ namespace ErsatzTV.Infrastructure.Data.Repositories .ToListAsync(); } - private async Task> GetShowItems(Collection collection) + private async Task> GetShowItems(TvContext dbContext, int collectionId) { IEnumerable ids = await _dbConnection.QueryAsync( @"SELECT Episode.Id FROM CollectionItem ci @@ -301,9 +124,9 @@ namespace ErsatzTV.Infrastructure.Data.Repositories INNER JOIN Season ON Season.ShowId = Show.Id INNER JOIN Episode ON Episode.SeasonId = Season.Id WHERE ci.CollectionId = @CollectionId", - new { CollectionId = collection.Id }); + new { CollectionId = collectionId }); - return await _dbContext.Episodes + return await dbContext.Episodes .Include(e => e.EpisodeMetadata) .Include(e => e.MediaVersions) .Include(e => e.Season) @@ -313,16 +136,16 @@ namespace ErsatzTV.Infrastructure.Data.Repositories .ToListAsync(); } - private async Task> GetSeasonItems(Collection collection) + private async Task> GetSeasonItems(TvContext dbContext, int collectionId) { IEnumerable ids = await _dbConnection.QueryAsync( @"SELECT Episode.Id FROM CollectionItem ci INNER JOIN Season ON Season.Id = ci.MediaItemId INNER JOIN Episode ON Episode.SeasonId = Season.Id WHERE ci.CollectionId = @CollectionId", - new { CollectionId = collection.Id }); + new { CollectionId = collectionId }); - return await _dbContext.Episodes + return await dbContext.Episodes .Include(e => e.EpisodeMetadata) .Include(e => e.MediaVersions) .Include(e => e.Season) @@ -332,15 +155,15 @@ namespace ErsatzTV.Infrastructure.Data.Repositories .ToListAsync(); } - private async Task> GetEpisodeItems(Collection collection) + private async Task> GetEpisodeItems(TvContext dbContext, int collectionId) { IEnumerable ids = await _dbConnection.QueryAsync( @"SELECT Episode.Id FROM CollectionItem ci INNER JOIN Episode ON Episode.Id = ci.MediaItemId WHERE ci.CollectionId = @CollectionId", - new { CollectionId = collection.Id }); + new { CollectionId = collectionId }); - return await _dbContext.Episodes + return await dbContext.Episodes .Include(e => e.EpisodeMetadata) .Include(e => e.MediaVersions) .Include(e => e.Season) diff --git a/ErsatzTV.Infrastructure/Data/Repositories/MediaItemRepository.cs b/ErsatzTV.Infrastructure/Data/Repositories/MediaItemRepository.cs index 532ee3d6a..3705ee4f3 100644 --- a/ErsatzTV.Infrastructure/Data/Repositories/MediaItemRepository.cs +++ b/ErsatzTV.Infrastructure/Data/Repositories/MediaItemRepository.cs @@ -3,47 +3,16 @@ using System.Data; using System.Linq; using System.Threading.Tasks; using Dapper; -using ErsatzTV.Core.Domain; using ErsatzTV.Core.Interfaces.Repositories; using LanguageExt; -using Microsoft.EntityFrameworkCore; -using static LanguageExt.Prelude; namespace ErsatzTV.Infrastructure.Data.Repositories { public class MediaItemRepository : IMediaItemRepository { private readonly IDbConnection _dbConnection; - private readonly IDbContextFactory _dbContextFactory; - public MediaItemRepository(IDbContextFactory dbContextFactory, IDbConnection dbConnection) - { - _dbContextFactory = dbContextFactory; - _dbConnection = dbConnection; - } - - public async Task> Get(int id) - { - await using TvContext context = _dbContextFactory.CreateDbContext(); - return await context.MediaItems - .Include(i => i.LibraryPath) - .OrderBy(i => i.Id) - .SingleOrDefaultAsync(i => i.Id == id) - .Map(Optional); - } - - public async Task> GetAll() - { - await using TvContext context = _dbContextFactory.CreateDbContext(); - return await context.MediaItems.ToListAsync(); - } - - public async Task Update(MediaItem mediaItem) - { - await using TvContext context = _dbContextFactory.CreateDbContext(); - context.MediaItems.Update(mediaItem); - return await context.SaveChangesAsync() > 0; - } + public MediaItemRepository(IDbConnection dbConnection) => _dbConnection = dbConnection; public Task> GetAllLanguageCodes() => _dbConnection.QueryAsync( diff --git a/ErsatzTV.Infrastructure/Data/Repositories/MediaSourceRepository.cs b/ErsatzTV.Infrastructure/Data/Repositories/MediaSourceRepository.cs index 2b397e398..70d794da0 100644 --- a/ErsatzTV.Infrastructure/Data/Repositories/MediaSourceRepository.cs +++ b/ErsatzTV.Infrastructure/Data/Repositories/MediaSourceRepository.cs @@ -24,14 +24,6 @@ namespace ErsatzTV.Infrastructure.Data.Repositories _dbConnection = dbConnection; } - public async Task Add(LocalMediaSource localMediaSource) - { - await using TvContext context = _dbContextFactory.CreateDbContext(); - await context.LocalMediaSources.AddAsync(localMediaSource); - await context.SaveChangesAsync(); - return localMediaSource; - } - public async Task Add(PlexMediaSource plexMediaSource) { await using TvContext context = _dbContextFactory.CreateDbContext(); @@ -40,18 +32,6 @@ namespace ErsatzTV.Infrastructure.Data.Repositories return plexMediaSource; } - public async Task> GetAll() - { - await using TvContext context = _dbContextFactory.CreateDbContext(); - List all = await context.MediaSources.ToListAsync(); - foreach (PlexMediaSource plex in all.OfType()) - { - await context.Entry(plex).Collection(p => p.Connections).LoadAsync(); - } - - return all; - } - public Task> GetAllPlex() { using TvContext context = _dbContextFactory.CreateDbContext(); @@ -87,15 +67,6 @@ namespace ErsatzTV.Infrastructure.Data.Repositories .Map(Optional); } - public Task> Get(int id) - { - using TvContext context = _dbContextFactory.CreateDbContext(); - return context.MediaSources - .OrderBy(s => s.Id) // https://github.com/dotnet/efcore/issues/22579 - .SingleOrDefaultAsync(s => s.Id == id) - .Map(Optional); - } - public Task> GetPlex(int id) { using TvContext context = _dbContextFactory.CreateDbContext(); @@ -140,20 +111,6 @@ namespace ErsatzTV.Infrastructure.Data.Repositories .ToListAsync(); } - public Task CountMediaItems(int id) - { - using TvContext context = _dbContextFactory.CreateDbContext(); - return context.MediaItems - .CountAsync(i => i.LibraryPath.Library.MediaSourceId == id); - } - - public async Task Update(LocalMediaSource localMediaSource) - { - await using TvContext context = _dbContextFactory.CreateDbContext(); - context.LocalMediaSources.Update(localMediaSource); - await context.SaveChangesAsync(); - } - public async Task Update( PlexMediaSource plexMediaSource, List sortedConnections, @@ -328,21 +285,6 @@ namespace ErsatzTV.Infrastructure.Data.Repositories return Unit.Default; } - public async Task Update(PlexLibrary plexMediaSourceLibrary) - { - await using TvContext context = _dbContextFactory.CreateDbContext(); - context.PlexLibraries.Update(plexMediaSourceLibrary); - await context.SaveChangesAsync(); - } - - public async Task Delete(int mediaSourceId) - { - await using TvContext context = _dbContextFactory.CreateDbContext(); - MediaSource mediaSource = await context.MediaSources.FindAsync(mediaSourceId); - context.MediaSources.Remove(mediaSource); - await context.SaveChangesAsync(); - } - public async Task> DeleteAllPlex() { await using TvContext context = _dbContextFactory.CreateDbContext(); diff --git a/ErsatzTV.Infrastructure/Data/Repositories/MovieRepository.cs b/ErsatzTV.Infrastructure/Data/Repositories/MovieRepository.cs index 1c16d3a37..1fa427253 100644 --- a/ErsatzTV.Infrastructure/Data/Repositories/MovieRepository.cs +++ b/ErsatzTV.Infrastructure/Data/Repositories/MovieRepository.cs @@ -139,25 +139,6 @@ namespace ErsatzTV.Infrastructure.Data.Repositories async () => await AddPlexMovie(context, library, item)); } - public Task GetMovieCount() => - _dbConnection.QuerySingleAsync(@"SELECT COUNT(DISTINCT MovieId) FROM MovieMetadata"); - - public async Task> GetPagedMovies(int pageNumber, int pageSize) - { - await using TvContext dbContext = _dbContextFactory.CreateDbContext(); - return await dbContext.MovieMetadata.FromSqlRaw( - @"SELECT * FROM MovieMetadata WHERE Id IN - (SELECT Id FROM MovieMetadata GROUP BY MovieId, MetadataKind HAVING MetadataKind = MAX(MetadataKind)) - ORDER BY SortTitle - LIMIT {0} OFFSET {1}", - pageSize, - (pageNumber - 1) * pageSize) - .AsNoTracking() - .Include(mm => mm.Artwork) - .OrderBy(mm => mm.SortTitle) - .ToListAsync(); - } - public async Task> GetMoviesForCards(List ids) { await using TvContext dbContext = _dbContextFactory.CreateDbContext(); diff --git a/ErsatzTV.Infrastructure/Data/Repositories/MusicVideoRepository.cs b/ErsatzTV.Infrastructure/Data/Repositories/MusicVideoRepository.cs index 46a633e49..d9cce4dae 100644 --- a/ErsatzTV.Infrastructure/Data/Repositories/MusicVideoRepository.cs +++ b/ErsatzTV.Infrastructure/Data/Repositories/MusicVideoRepository.cs @@ -131,23 +131,6 @@ namespace ErsatzTV.Infrastructure.Data.Repositories .ToListAsync(); } - public async Task> GetMusicVideo(int musicVideoId) - { - await using TvContext dbContext = _dbContextFactory.CreateDbContext(); - return await dbContext.MusicVideos - .Include(m => m.MusicVideoMetadata) - .ThenInclude(m => m.Artwork) - .Include(m => m.MusicVideoMetadata) - .ThenInclude(m => m.Genres) - .Include(m => m.MusicVideoMetadata) - .ThenInclude(m => m.Tags) - .Include(m => m.MusicVideoMetadata) - .ThenInclude(m => m.Studios) - .OrderBy(m => m.Id) - .SingleOrDefaultAsync(m => m.Id == musicVideoId) - .Map(Optional); - } - public Task> FindOrphanPaths(LibraryPath libraryPath) => _dbConnection.QueryAsync( @"SELECT MF.Path diff --git a/ErsatzTV.Infrastructure/Data/Repositories/PlayoutRepository.cs b/ErsatzTV.Infrastructure/Data/Repositories/PlayoutRepository.cs deleted file mode 100644 index efa8c784d..000000000 --- a/ErsatzTV.Infrastructure/Data/Repositories/PlayoutRepository.cs +++ /dev/null @@ -1,144 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using ErsatzTV.Core.Domain; -using ErsatzTV.Core.Interfaces.Repositories; -using LanguageExt; -using Microsoft.EntityFrameworkCore; -using static LanguageExt.Prelude; - -namespace ErsatzTV.Infrastructure.Data.Repositories -{ - public class PlayoutRepository : IPlayoutRepository - { - private readonly TvContext _dbContext; - private readonly IDbContextFactory _dbContextFactory; - - public PlayoutRepository(TvContext dbContext, IDbContextFactory dbContextFactory) - { - _dbContext = dbContext; - _dbContextFactory = dbContextFactory; - } - - public async Task Add(Playout playout) - { - await _dbContext.Playouts.AddAsync(playout); - await _dbContext.SaveChangesAsync(); - return playout; - } - - public Task> Get(int id) => - _dbContext.Playouts - .OrderBy(p => p.Id) - .SingleOrDefaultAsync(p => p.Id == id) - .Map(Optional); - - public async Task> GetFull(int id) => - await _dbContext.Playouts - .Include(p => p.Channel) - .Include(p => p.Items) - .Include(p => p.ProgramScheduleAnchors) - .ThenInclude(a => a.MediaItem) - .Include(p => p.ProgramSchedule) - .ThenInclude(ps => ps.Items) - .ThenInclude(psi => psi.Collection) - .Include(p => p.ProgramSchedule) - .ThenInclude(ps => ps.Items) - .ThenInclude(psi => psi.MediaItem) - .OrderBy(p => p.Id) // https://github.com/dotnet/efcore/issues/22579#issuecomment-694772289 - .SingleOrDefaultAsync(p => p.Id == id); - - public Task> GetPlayoutItem(int channelId, DateTimeOffset now) => - _dbContext.PlayoutItems - .Where(pi => pi.Playout.ChannelId == channelId) - .Where(pi => pi.Start <= now.UtcDateTime && pi.Finish > now.UtcDateTime) - .Include(i => i.MediaItem) - .ThenInclude(mi => (mi as Episode).MediaVersions) - .ThenInclude(mv => mv.MediaFiles) - .Include(i => i.MediaItem) - .ThenInclude(mi => (mi as Episode).MediaVersions) - .ThenInclude(mv => mv.Streams) - .Include(i => i.MediaItem) - .ThenInclude(mi => (mi as Movie).MediaVersions) - .ThenInclude(mv => mv.MediaFiles) - .Include(i => i.MediaItem) - .ThenInclude(mi => (mi as Movie).MediaVersions) - .ThenInclude(mv => mv.Streams) - .Include(i => i.MediaItem) - .ThenInclude(mi => (mi as MusicVideo).MediaVersions) - .ThenInclude(mv => mv.MediaFiles) - .Include(i => i.MediaItem) - .ThenInclude(mi => (mi as MusicVideo).MediaVersions) - .ThenInclude(mv => mv.Streams) - .AsNoTracking() - .OrderBy(pi => pi.Start) - .SingleOrDefaultAsync() - .Map(Optional); - - public Task> GetNextItemStart(int channelId, DateTimeOffset now) => - _dbContext.PlayoutItems - .Where(pi => pi.Playout.ChannelId == channelId) - .Where(pi => pi.Start > now.UtcDateTime) - .OrderBy(pi => pi.Start) - .FirstOrDefaultAsync() - .Map(Optional) - .MapT(pi => pi.StartOffset); - - public async Task> GetPlayoutItems(int playoutId) - { - await using TvContext context = _dbContextFactory.CreateDbContext(); - return await context.PlayoutItems - .AsNoTracking() - .Include(i => i.MediaItem) - .ThenInclude(mi => (mi as Movie).MovieMetadata) - .ThenInclude(mm => mm.Artwork) - .Include(i => i.MediaItem) - .ThenInclude(mi => (mi as Movie).MediaVersions) - .Include(i => i.MediaItem) - .ThenInclude(mi => (mi as MusicVideo).MusicVideoMetadata) - .ThenInclude(mm => mm.Artwork) - .Include(i => i.MediaItem) - .ThenInclude(mi => (mi as MusicVideo).MediaVersions) - .Include(i => i.MediaItem) - .ThenInclude(mi => (mi as MusicVideo).Artist) - .ThenInclude(mm => mm.ArtistMetadata) - .Include(i => i.MediaItem) - .ThenInclude(mi => (mi as Episode).EpisodeMetadata) - .ThenInclude(em => em.Artwork) - .Include(i => i.MediaItem) - .ThenInclude(mi => (mi as Episode).MediaVersions) - .Include(i => i.MediaItem) - .ThenInclude(mi => (mi as Episode).Season) - .ThenInclude(s => s.SeasonMetadata) - .Include(i => i.MediaItem) - .ThenInclude(mi => (mi as Episode).Season.Show) - .ThenInclude(s => s.ShowMetadata) - .Filter(i => i.PlayoutId == playoutId) - .ToListAsync(); - } - - public async Task> GetAll() - { - await using TvContext context = _dbContextFactory.CreateDbContext(); - return await context.Playouts - .AsNoTracking() - .Include(p => p.Channel) - .Include(p => p.ProgramSchedule) - .ToListAsync(); - } - - public Task Update(Playout playout) - { - _dbContext.Playouts.Update(playout); - return _dbContext.SaveChangesAsync(); - } - - public async Task Delete(int playoutId) - { - Playout playout = await _dbContext.Playouts.FindAsync(playoutId); - _dbContext.Playouts.Remove(playout); - await _dbContext.SaveChangesAsync(); - } - } -} diff --git a/ErsatzTV.Infrastructure/Data/Repositories/ProgramScheduleRepository.cs b/ErsatzTV.Infrastructure/Data/Repositories/ProgramScheduleRepository.cs deleted file mode 100644 index 79541735e..000000000 --- a/ErsatzTV.Infrastructure/Data/Repositories/ProgramScheduleRepository.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using ErsatzTV.Core.Domain; -using ErsatzTV.Core.Interfaces.Repositories; -using LanguageExt; -using Microsoft.EntityFrameworkCore; -using static LanguageExt.Prelude; - -namespace ErsatzTV.Infrastructure.Data.Repositories -{ - public class ProgramScheduleRepository : IProgramScheduleRepository - { - private readonly TvContext _dbContext; - - public ProgramScheduleRepository(TvContext dbContext) => _dbContext = dbContext; - - public async Task Add(ProgramSchedule programSchedule) - { - await _dbContext.ProgramSchedules.AddAsync(programSchedule); - await _dbContext.SaveChangesAsync(); - return programSchedule; - } - - public Task> Get(int id) => - _dbContext.ProgramSchedules - .OrderBy(s => s.Id) - .SingleOrDefaultAsync(s => s.Id == id) - .Map(Optional); - - public async Task> GetWithPlayouts(int id) => - await _dbContext.ProgramSchedules - .Include(ps => ps.Items) - .Include(ps => ps.Playouts) - .OrderBy(ps => ps.Id) - .SingleOrDefaultAsync(ps => ps.Id == id); - - public Task> GetAll() => - _dbContext.ProgramSchedules.ToListAsync(); - - public async Task Update(ProgramSchedule programSchedule) - { - _dbContext.ProgramSchedules.Update(programSchedule); - await _dbContext.SaveChangesAsync(); - await _dbContext.Entry(programSchedule).Collection(s => s.Items).Query().Include(i => i.Collection) - .LoadAsync(); - await _dbContext.Entry(programSchedule).Collection(s => s.Playouts).LoadAsync(); - } - - public async Task Delete(int programScheduleId) - { - ProgramSchedule programSchedule = await _dbContext.ProgramSchedules.FindAsync(programScheduleId); - _dbContext.ProgramSchedules.Remove(programSchedule); - await _dbContext.SaveChangesAsync(); - } - - public async Task>> GetItems(int programScheduleId) - { - Option maybeSchedule = await Get(programScheduleId); - return await maybeSchedule.Map( - async programSchedule => - { - await _dbContext.Entry(programSchedule).Collection(s => s.Items).LoadAsync(); - await _dbContext.Entry(programSchedule).Collection(s => s.Items).Query() - .Include(i => i.Collection) - .Include(i => i.MediaItem) - .ThenInclude(i => (i as Movie).MovieMetadata) - .ThenInclude(mm => mm.Artwork) - .Include(i => i.MediaItem) - .ThenInclude(i => (i as Season).SeasonMetadata) - .ThenInclude(sm => sm.Artwork) - .Include(i => i.MediaItem) - .ThenInclude(i => (i as Season).Show) - .ThenInclude(s => s.ShowMetadata) - .ThenInclude(sm => sm.Artwork) - .Include(i => i.MediaItem) - .ThenInclude(i => (i as Show).ShowMetadata) - .ThenInclude(sm => sm.Artwork) - .Include(i => i.MediaItem) - .ThenInclude(i => (i as Artist).ArtistMetadata) - .ThenInclude(am => am.Artwork) - .LoadAsync(); - return programSchedule.Items; - }).Sequence(); - } - } -} diff --git a/ErsatzTV.Infrastructure/Data/Repositories/ResolutionRepository.cs b/ErsatzTV.Infrastructure/Data/Repositories/ResolutionRepository.cs deleted file mode 100644 index 0cbe4b81c..000000000 --- a/ErsatzTV.Infrastructure/Data/Repositories/ResolutionRepository.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using ErsatzTV.Core.Domain; -using ErsatzTV.Core.Interfaces.Repositories; -using LanguageExt; -using Microsoft.EntityFrameworkCore; -using static LanguageExt.Prelude; - -namespace ErsatzTV.Infrastructure.Data.Repositories -{ - public class ResolutionRepository : IResolutionRepository - { - private readonly TvContext _dbContext; - - public ResolutionRepository(TvContext dbContext) => _dbContext = dbContext; - - public Task> Get(int id) => - _dbContext.Resolutions - .OrderBy(r => r.Id) - .SingleOrDefaultAsync(r => r.Id == id) - .Map(Optional); - - public Task> GetAll() => - _dbContext.Resolutions.ToListAsync(); - } -} diff --git a/ErsatzTV.Infrastructure/Data/Repositories/TelevisionRepository.cs b/ErsatzTV.Infrastructure/Data/Repositories/TelevisionRepository.cs index 21642169a..a46512c44 100644 --- a/ErsatzTV.Infrastructure/Data/Repositories/TelevisionRepository.cs +++ b/ErsatzTV.Infrastructure/Data/Repositories/TelevisionRepository.cs @@ -162,19 +162,6 @@ namespace ErsatzTV.Infrastructure.Data.Repositories .ToListAsync(); } - public async Task> GetEpisode(int episodeId) - { - await using TvContext dbContext = _dbContextFactory.CreateDbContext(); - return await dbContext.Episodes - .AsNoTracking() - .Include(e => e.Season) - .Include(e => e.EpisodeMetadata) - .ThenInclude(em => em.Artwork) - .OrderBy(s => s.Id) - .SingleOrDefaultAsync(s => s.Id == episodeId) - .Map(Optional); - } - public async Task GetEpisodeCount(int seasonId) { await using TvContext dbContext = _dbContextFactory.CreateDbContext(); diff --git a/ErsatzTV.Infrastructure/Data/TvContext.cs b/ErsatzTV.Infrastructure/Data/TvContext.cs index 6392dbc1c..afdd9f856 100644 --- a/ErsatzTV.Infrastructure/Data/TvContext.cs +++ b/ErsatzTV.Infrastructure/Data/TvContext.cs @@ -58,6 +58,7 @@ namespace ErsatzTV.Infrastructure.Data public DbSet Collections { get; set; } public DbSet CollectionItems { get; set; } public DbSet ProgramSchedules { get; set; } + public DbSet ProgramScheduleItems { get; set; } public DbSet Playouts { get; set; } public DbSet PlayoutItems { get; set; } public DbSet PlayoutProgramScheduleItemAnchors { get; set; } diff --git a/ErsatzTV.Infrastructure/Extensions/ConfigElementQueryableExtensions.cs b/ErsatzTV.Infrastructure/Extensions/ConfigElementQueryableExtensions.cs new file mode 100644 index 000000000..2a6f70255 --- /dev/null +++ b/ErsatzTV.Infrastructure/Extensions/ConfigElementQueryableExtensions.cs @@ -0,0 +1,18 @@ +using System; +using System.Linq; +using System.Threading.Tasks; +using ErsatzTV.Core.Domain; +using LanguageExt; + +namespace ErsatzTV.Infrastructure.Extensions +{ + public static class ConfigElementQueryableExtensions + { + public static Task> GetValue( + this IQueryable configElements, + ConfigElementKey key) => + configElements + .SelectOneAsync(ce => ce.Key, ce => ce.Key == key.Key) + .MapT(ce => (T) Convert.ChangeType(ce.Value, typeof(T))); + } +} diff --git a/ErsatzTV.Infrastructure/Extensions/PlayoutItemQueryableExtensions.cs b/ErsatzTV.Infrastructure/Extensions/PlayoutItemQueryableExtensions.cs new file mode 100644 index 000000000..db4a49b57 --- /dev/null +++ b/ErsatzTV.Infrastructure/Extensions/PlayoutItemQueryableExtensions.cs @@ -0,0 +1,23 @@ +using System; +using System.Linq; +using System.Threading.Tasks; +using ErsatzTV.Core.Domain; +using LanguageExt; +using Microsoft.EntityFrameworkCore; +using static LanguageExt.Prelude; + +namespace ErsatzTV.Infrastructure.Extensions +{ + public static class PlayoutItemQueryableExtensions + { + public static Task> ForChannelAndTime( + this IQueryable dbSet, + int channelId, + DateTimeOffset time) => + dbSet.Filter(pi => pi.Playout.ChannelId == channelId) + .Filter(pi => pi.Start <= time.UtcDateTime && pi.Finish > time.UtcDateTime) + .OrderBy(pi => pi.Start) + .FirstOrDefaultAsync() + .Map(Optional); + } +} diff --git a/ErsatzTV.Infrastructure/Extensions/QueryableExtensions.cs b/ErsatzTV.Infrastructure/Extensions/QueryableExtensions.cs new file mode 100644 index 000000000..394b4436f --- /dev/null +++ b/ErsatzTV.Infrastructure/Extensions/QueryableExtensions.cs @@ -0,0 +1,18 @@ +using System; +using System.Linq; +using System.Linq.Expressions; +using System.Threading.Tasks; +using LanguageExt; +using Microsoft.EntityFrameworkCore; + +namespace ErsatzTV.Infrastructure.Extensions +{ + public static class QueryableExtensions + { + public static async Task> SelectOneAsync( + this IQueryable enumerable, + Expression> keySelector, + Expression> predicate) where T : class => + await enumerable.OrderBy(keySelector).FirstOrDefaultAsync(predicate); + } +} diff --git a/ErsatzTV.sln b/ErsatzTV.sln index 05ba42079..e9e62455a 100644 --- a/ErsatzTV.sln +++ b/ErsatzTV.sln @@ -2,10 +2,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ErsatzTV", "ErsatzTV\ErsatzTV.csproj", "{E83551AD-27E4-46E5-AD06-5B0DF797B8FF}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ErsatzTV.CommandLine", "ErsatzTV.CommandLine\ErsatzTV.CommandLine.csproj", "{B3615FB4-9A0A-419F-AB49-CD162B14AC9A}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ErsatzTV.Api.Sdk", "generated\ErsatzTV.Api.Sdk\src\ErsatzTV.Api.Sdk\ErsatzTV.Api.Sdk.csproj", "{2926C44D-6351-4E57-976D-E7A5919CC406}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ErsatzTV.Infrastructure", "ErsatzTV.Infrastructure\ErsatzTV.Infrastructure.csproj", "{C56FC23D-B863-401E-8E7C-E92BC307AFC1}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ErsatzTV.Core", "ErsatzTV.Core\ErsatzTV.Core.csproj", "{BAC52351-F5CC-47A7-9C60-3E9551A3E26A}" @@ -24,14 +20,6 @@ Global {E83551AD-27E4-46E5-AD06-5B0DF797B8FF}.Debug|Any CPU.Build.0 = Debug|Any CPU {E83551AD-27E4-46E5-AD06-5B0DF797B8FF}.Release|Any CPU.ActiveCfg = Release|Any CPU {E83551AD-27E4-46E5-AD06-5B0DF797B8FF}.Release|Any CPU.Build.0 = Release|Any CPU - {B3615FB4-9A0A-419F-AB49-CD162B14AC9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B3615FB4-9A0A-419F-AB49-CD162B14AC9A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B3615FB4-9A0A-419F-AB49-CD162B14AC9A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B3615FB4-9A0A-419F-AB49-CD162B14AC9A}.Release|Any CPU.Build.0 = Release|Any CPU - {2926C44D-6351-4E57-976D-E7A5919CC406}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2926C44D-6351-4E57-976D-E7A5919CC406}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2926C44D-6351-4E57-976D-E7A5919CC406}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2926C44D-6351-4E57-976D-E7A5919CC406}.Release|Any CPU.Build.0 = Release|Any CPU {C56FC23D-B863-401E-8E7C-E92BC307AFC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C56FC23D-B863-401E-8E7C-E92BC307AFC1}.Debug|Any CPU.Build.0 = Debug|Any CPU {C56FC23D-B863-401E-8E7C-E92BC307AFC1}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/ErsatzTV/Controllers/Api/ChannelsController.cs b/ErsatzTV/Controllers/Api/ChannelsController.cs deleted file mode 100644 index 4b6e76c0e..000000000 --- a/ErsatzTV/Controllers/Api/ChannelsController.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Threading.Tasks; -using ErsatzTV.Application.Channels; -using ErsatzTV.Application.Channels.Commands; -using ErsatzTV.Application.Channels.Queries; -using ErsatzTV.Extensions; -using MediatR; -using Microsoft.AspNetCore.Mvc; - -namespace ErsatzTV.Controllers.Api -{ - [ApiController] - [Route("api/channels")] - [Produces("application/json")] - public class ChannelsController : ControllerBase - { - private readonly IMediator _mediator; - - public ChannelsController(IMediator mediator) => _mediator = mediator; - - [HttpPost] - [ProducesResponseType(typeof(ChannelViewModel), 200)] - [ProducesResponseType(400)] - public Task Add( - [Required] [FromBody] - CreateChannel createChannel) => - _mediator.Send(createChannel).ToActionResult(); - - [HttpGet("{channelId}")] - [ProducesResponseType(typeof(ChannelViewModel), 200)] - [ProducesResponseType(404)] - public Task Get(int channelId) => - _mediator.Send(new GetChannelById(channelId)).ToActionResult(); - - [HttpGet] - [ProducesResponseType(typeof(IEnumerable), 200)] - public Task GetAll() => - _mediator.Send(new GetAllChannels()).ToActionResult(); - - [HttpPatch] - [ProducesResponseType(typeof(ChannelViewModel), 200)] - [ProducesResponseType(400)] - public Task Update( - [Required] [FromBody] - UpdateChannel updateChannel) => - _mediator.Send(updateChannel).ToActionResult(); - - [HttpDelete] - [ProducesResponseType(200)] - [ProducesResponseType(400)] - public Task Delete( - [Required] [FromBody] - DeleteChannel deleteChannel) => - _mediator.Send(deleteChannel).ToActionResult(); - } -} diff --git a/ErsatzTV/Controllers/Api/FFmpegProfileController.cs b/ErsatzTV/Controllers/Api/FFmpegProfileController.cs deleted file mode 100644 index 3e08925be..000000000 --- a/ErsatzTV/Controllers/Api/FFmpegProfileController.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Threading.Tasks; -using ErsatzTV.Application.FFmpegProfiles; -using ErsatzTV.Application.FFmpegProfiles.Commands; -using ErsatzTV.Application.FFmpegProfiles.Queries; -using ErsatzTV.Extensions; -using MediatR; -using Microsoft.AspNetCore.Mvc; - -namespace ErsatzTV.Controllers.Api -{ - [ApiController] - [Route("api/ffmpeg/profiles")] - [Produces("application/json")] - public class FFmpegProfileController : ControllerBase - { - private readonly IMediator _mediator; - - public FFmpegProfileController(IMediator mediator) => _mediator = mediator; - - [HttpPost] - [ProducesResponseType(typeof(FFmpegProfileViewModel), 200)] - [ProducesResponseType(400)] - public Task Add( - [Required] [FromBody] - CreateFFmpegProfile createFFmpegProfile) => - _mediator.Send(createFFmpegProfile).ToActionResult(); - - [HttpGet("{ffmpegProfileId}")] - [ProducesResponseType(typeof(FFmpegProfileViewModel), 200)] - [ProducesResponseType(404)] - public Task Get(int ffmpegProfileId) => - _mediator.Send(new GetFFmpegProfileById(ffmpegProfileId)).ToActionResult(); - - [HttpGet] - [ProducesResponseType(typeof(IEnumerable), 200)] - public Task GetAll() => - _mediator.Send(new GetAllFFmpegProfiles()).ToActionResult(); - - [HttpPatch] - [ProducesResponseType(typeof(FFmpegProfileViewModel), 200)] - [ProducesResponseType(400)] - public Task Update( - [Required] [FromBody] - UpdateFFmpegProfile updateFFmpegProfile) => - _mediator.Send(updateFFmpegProfile).ToActionResult(); - - [HttpDelete] - [ProducesResponseType(200)] - [ProducesResponseType(400)] - public Task Delete( - [Required] [FromBody] - DeleteFFmpegProfile deleteFFmpegProfile) => - _mediator.Send(deleteFFmpegProfile).ToActionResult(); - } -} diff --git a/ErsatzTV/Controllers/Api/MediaCollectionsController.cs b/ErsatzTV/Controllers/Api/MediaCollectionsController.cs deleted file mode 100644 index a45f5f95b..000000000 --- a/ErsatzTV/Controllers/Api/MediaCollectionsController.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Threading.Tasks; -using ErsatzTV.Application.MediaCollections; -using ErsatzTV.Application.MediaCollections.Commands; -using ErsatzTV.Application.MediaCollections.Queries; -using ErsatzTV.Application.MediaItems; -using ErsatzTV.Extensions; -using MediatR; -using Microsoft.AspNetCore.Mvc; - -namespace ErsatzTV.Controllers.Api -{ - [ApiController] - [Route("api/media/collections")] - [Produces("application/json")] - public class MediaCollectionsController : ControllerBase - { - private readonly IMediator _mediator; - - public MediaCollectionsController(IMediator mediator) => _mediator = mediator; - - [HttpPost] - [ProducesResponseType(typeof(MediaCollectionViewModel), 200)] - [ProducesResponseType(400)] - public Task Add( - [Required] [FromBody] - CreateCollection createCollection) => - _mediator.Send(createCollection).ToActionResult(); - - [HttpGet] - [ProducesResponseType(typeof(IEnumerable), 200)] - public Task GetAll() => - _mediator.Send(new GetAllCollections()).ToActionResult(); - - [HttpGet("{id}")] - [ProducesResponseType(typeof(MediaCollectionViewModel), 200)] - [ProducesResponseType(404)] - public Task Get(int id) => - _mediator.Send(new GetCollectionById(id)).ToActionResult(); - - [HttpGet("{id}/items")] - [ProducesResponseType(typeof(IEnumerable), 200)] - [ProducesResponseType(404)] - public Task GetItems(int id) => - _mediator.Send(new GetCollectionItems(id)).ToActionResult(); - } -} diff --git a/ErsatzTV/Controllers/Api/MediaItemsController.cs b/ErsatzTV/Controllers/Api/MediaItemsController.cs deleted file mode 100644 index a6f3779bd..000000000 --- a/ErsatzTV/Controllers/Api/MediaItemsController.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using ErsatzTV.Application.MediaItems; -using ErsatzTV.Application.MediaItems.Queries; -using ErsatzTV.Extensions; -using MediatR; -using Microsoft.AspNetCore.Mvc; - -namespace ErsatzTV.Controllers.Api -{ - [ApiController] - [Route("api/media/items")] - [Produces("application/json")] - public class MediaItemsController : ControllerBase - { - private readonly IMediator _mediator; - - public MediaItemsController(IMediator mediator) => _mediator = mediator; - - [HttpGet("{mediaItemId}")] - [ProducesResponseType(typeof(MediaItemViewModel), 200)] - [ProducesResponseType(404)] - public Task Get(int mediaItemId) => - _mediator.Send(new GetMediaItemById(mediaItemId)).ToActionResult(); - - [HttpGet] - [ProducesResponseType(typeof(IEnumerable), 200)] - public Task GetAll() => - _mediator.Send(new GetAllMediaItems()).ToActionResult(); - } -} diff --git a/ErsatzTV/Controllers/Api/MediaSourcesController.cs b/ErsatzTV/Controllers/Api/MediaSourcesController.cs deleted file mode 100644 index 6b4beffdc..000000000 --- a/ErsatzTV/Controllers/Api/MediaSourcesController.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using ErsatzTV.Application.MediaSources; -using ErsatzTV.Application.MediaSources.Queries; -using ErsatzTV.Extensions; -using MediatR; -using Microsoft.AspNetCore.Mvc; - -namespace ErsatzTV.Controllers.Api -{ - [ApiController] - [Route("api/media/sources")] - [Produces("application/json")] - public class MediaSourcesController : ControllerBase - { - private readonly IMediator _mediator; - - public MediaSourcesController(IMediator mediator) => _mediator = mediator; - - [HttpGet] - [ProducesResponseType(typeof(IEnumerable), 200)] - public Task GetAll() => - _mediator.Send(new GetAllMediaSources()).ToActionResult(); - - [HttpGet("{id}")] - [ProducesResponseType(typeof(MediaSourceViewModel), 200)] - [ProducesResponseType(404)] - public Task Get(int id) => - _mediator.Send(new GetMediaSourceById(id)).ToActionResult(); - } -} diff --git a/ErsatzTV/Controllers/Api/PlayoutController.cs b/ErsatzTV/Controllers/Api/PlayoutController.cs deleted file mode 100644 index b0422b9af..000000000 --- a/ErsatzTV/Controllers/Api/PlayoutController.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Threading.Tasks; -using ErsatzTV.Application.Playouts; -using ErsatzTV.Application.Playouts.Commands; -using ErsatzTV.Application.Playouts.Queries; -using ErsatzTV.Extensions; -using MediatR; -using Microsoft.AspNetCore.Mvc; - -namespace ErsatzTV.Controllers.Api -{ - [ApiController] - [Route("api/playouts")] - [Produces("application/json")] - public class PlayoutController : ControllerBase - { - private readonly IMediator _mediator; - - public PlayoutController(IMediator mediator) => _mediator = mediator; - - [HttpPost] - [ProducesResponseType(typeof(PlayoutViewModel), 200)] - [ProducesResponseType(400)] - public Task Add( - [Required] [FromBody] - CreatePlayout createPlayout) => - _mediator.Send(createPlayout).ToActionResult(); - - [HttpGet("{playoutId}")] - [ProducesResponseType(typeof(PlayoutViewModel), 200)] - [ProducesResponseType(404)] - public Task Get(int playoutId) => - _mediator.Send(new GetPlayoutById(playoutId)).ToActionResult(); - - [HttpGet] - [ProducesResponseType(typeof(IEnumerable), 200)] - public Task GetAll() => - _mediator.Send(new GetAllPlayouts()).ToActionResult(); - - [HttpPatch] - [ProducesResponseType(typeof(PlayoutViewModel), 200)] - [ProducesResponseType(400)] - public Task Update( - [Required] [FromBody] - UpdatePlayout updatePlayout) => - _mediator.Send(updatePlayout).ToActionResult(); - - [HttpDelete] - [ProducesResponseType(200)] - [ProducesResponseType(400)] - public Task Delete( - [Required] [FromBody] - DeletePlayout deletePlayout) => - _mediator.Send(deletePlayout).ToActionResult(); - } -} diff --git a/ErsatzTV/Controllers/Api/ProgramScheduleController.cs b/ErsatzTV/Controllers/Api/ProgramScheduleController.cs deleted file mode 100644 index 90fe2068a..000000000 --- a/ErsatzTV/Controllers/Api/ProgramScheduleController.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Threading.Tasks; -using ErsatzTV.Application.ProgramSchedules; -using ErsatzTV.Application.ProgramSchedules.Commands; -using ErsatzTV.Application.ProgramSchedules.Queries; -using ErsatzTV.Extensions; -using MediatR; -using Microsoft.AspNetCore.Mvc; - -namespace ErsatzTV.Controllers.Api -{ - [ApiController] - [Route("api/schedules")] - [Produces("application/json")] - public class ProgramScheduleController : ControllerBase - { - private readonly IMediator _mediator; - - public ProgramScheduleController(IMediator mediator) => _mediator = mediator; - - [HttpPost] - [ProducesResponseType(typeof(ProgramScheduleViewModel), 200)] - [ProducesResponseType(400)] - public Task Add( - [Required] [FromBody] - CreateProgramSchedule createProgramSchedule) => - _mediator.Send(createProgramSchedule).ToActionResult(); - - [HttpGet("{programScheduleId}")] - [ProducesResponseType(typeof(ProgramScheduleViewModel), 200)] - [ProducesResponseType(404)] - public Task Get(int programScheduleId) => - _mediator.Send(new GetProgramScheduleById(programScheduleId)).ToActionResult(); - - [HttpGet] - [ProducesResponseType(typeof(IEnumerable), 200)] - public Task GetAll() => - _mediator.Send(new GetAllProgramSchedules()).ToActionResult(); - - [HttpPatch] - [ProducesResponseType(typeof(ProgramScheduleViewModel), 200)] - [ProducesResponseType(400)] - public Task Update( - [Required] [FromBody] - UpdateProgramSchedule updateProgramSchedule) => - _mediator.Send(updateProgramSchedule).ToActionResult(); - - [HttpDelete] - [ProducesResponseType(200)] - [ProducesResponseType(400)] - public Task Delete( - [Required] [FromBody] - DeleteProgramSchedule deleteProgramSchedule) => - _mediator.Send(deleteProgramSchedule).ToActionResult(); - - [HttpGet("{programScheduleId}/items")] - [ProducesResponseType(typeof(IEnumerable), 200)] - [ProducesResponseType(404)] - public Task GetItems(int programScheduleId) => - _mediator.Send(new GetProgramScheduleItems(programScheduleId)).ToActionResult(); - - [HttpPut("{programScheduleId}/items")] - [ProducesResponseType(typeof(IEnumerable), 200)] - [ProducesResponseType(404)] - public Task PutItems( - int programScheduleId, - [Required] [FromBody] - List items) => - _mediator.Send(new ReplaceProgramScheduleItems(programScheduleId, items)).ToActionResult(); - - [HttpDelete("{programScheduleId}/items")] - [ProducesResponseType(typeof(IEnumerable), 200)] - [ProducesResponseType(404)] - public Task DeleteItems(int programScheduleId) => - _mediator.Send(new ReplaceProgramScheduleItems(programScheduleId, new List())) - .ToActionResult(); - - [HttpPost("items/add")] - [ProducesResponseType(typeof(IEnumerable), 200)] - [ProducesResponseType(404)] - public Task AddItem( - [Required] [FromBody] - AddProgramScheduleItem addProgramScheduleItem) => - _mediator.Send(addProgramScheduleItem).ToActionResult(); - } -} diff --git a/ErsatzTV/ErsatzTV.csproj b/ErsatzTV/ErsatzTV.csproj index 2c34fd03d..e15fbbda7 100644 --- a/ErsatzTV/ErsatzTV.csproj +++ b/ErsatzTV/ErsatzTV.csproj @@ -41,8 +41,6 @@ - - diff --git a/ErsatzTV/Pages/Playouts.razor b/ErsatzTV/Pages/Playouts.razor index 75807e45d..33731adf4 100644 --- a/ErsatzTV/Pages/Playouts.razor +++ b/ErsatzTV/Pages/Playouts.razor @@ -6,7 +6,7 @@ @inject IMediator _mediator - + Playouts @@ -30,8 +30,8 @@ - @context.Channel.Number - @context.Channel.Name - @context.ProgramSchedule.Name + @context.ChannelNumber - @context.ChannelName + @context.ScheduleName @* @context.ProgramSchedulePlayoutType *@
@@ -80,38 +80,38 @@ @code { - private List _playouts; + private List _playouts; private List _selectedPlayoutItems; private int? _selectedPlayoutId; protected override Task OnParametersSetAsync() => LoadAllPlayouts(); - private async Task PlayoutSelected(PlayoutViewModel playout) + private async Task PlayoutSelected(PlayoutNameViewModel playout) { - _selectedPlayoutId = playout.Id; - _selectedPlayoutItems = await _mediator.Send(new GetPlayoutItemsById(playout.Id)); + _selectedPlayoutId = playout.PlayoutId; + _selectedPlayoutItems = await _mediator.Send(new GetPlayoutItemsById(playout.PlayoutId)); } - private async Task DeletePlayout(PlayoutViewModel playout) + private async Task DeletePlayout(PlayoutNameViewModel playout) { - var parameters = new DialogParameters { { "EntityType", "playout" }, { "EntityName", $"{playout.ProgramSchedule.Name} on {playout.Channel.Number} - {playout.Channel.Name}" } }; + var parameters = new DialogParameters { { "EntityType", "playout" }, { "EntityName", $"{playout.ScheduleName} on {playout.ChannelNumber} - {playout.ChannelName}" } }; var options = new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall }; IDialogReference dialog = _dialog.Show("Delete Playout", parameters, options); DialogResult result = await dialog.Result; if (!result.Cancelled) { - await _mediator.Send(new DeletePlayout(playout.Id)); + await _mediator.Send(new DeletePlayout(playout.PlayoutId)); await LoadAllPlayouts(); } } - private async Task RebuildPlayout(PlayoutViewModel playout) + private async Task RebuildPlayout(PlayoutNameViewModel playout) { - await _mediator.Send(new BuildPlayout(playout.Id, true)); + await _mediator.Send(new BuildPlayout(playout.PlayoutId, true)); await LoadAllPlayouts(); - if (_selectedPlayoutId == playout.Id) + if (_selectedPlayoutId == playout.PlayoutId) { await PlayoutSelected(playout); } @@ -119,7 +119,7 @@ private async Task LoadAllPlayouts() => _playouts = await _mediator.Send(new GetAllPlayouts()) - .Map(list => list.OrderBy(x => decimal.Parse(x.Channel.Number)).ToList()); + .Map(list => list.OrderBy(x => decimal.Parse(x.ChannelNumber)).ToList()); } \ No newline at end of file diff --git a/ErsatzTV/Pages/ScheduleEditor.razor b/ErsatzTV/Pages/ScheduleEditor.razor index f23877e4b..f9162fffc 100644 --- a/ErsatzTV/Pages/ScheduleEditor.razor +++ b/ErsatzTV/Pages/ScheduleEditor.razor @@ -92,9 +92,9 @@ _messageStore.Clear(); if (_editContext.Validate()) { - Either result = IsEdit ? - await _mediator.Send(_model.ToUpdate()) : - await _mediator.Send(_model.ToCreate()); + Either result = IsEdit ? + await _mediator.Send(_model.ToUpdate()).MapT(r => r as EntityIdResult) : + await _mediator.Send(_model.ToCreate()).MapT(r => r as EntityIdResult); result.Match( programSchedule => diff --git a/ErsatzTV/Pages/Schedules.razor b/ErsatzTV/Pages/Schedules.razor index 051b46300..eebf04978 100644 --- a/ErsatzTV/Pages/Schedules.razor +++ b/ErsatzTV/Pages/Schedules.razor @@ -92,7 +92,7 @@ { _selectedSchedule = schedule; await _mediator.Send(new GetProgramScheduleItems(schedule.Id)) - .IterT(results => _selectedScheduleItems = results.OrderBy(x => x.Name).ToList()); + .Map(results => _selectedScheduleItems = results.OrderBy(x => x.Name).ToList()); } private async Task DeleteSchedule(ProgramScheduleViewModel programSchedule) diff --git a/ErsatzTV/Services/RunOnce/PlatformSettingsService.cs b/ErsatzTV/Services/RunOnce/PlatformSettingsService.cs index 209148064..b407f6ac9 100644 --- a/ErsatzTV/Services/RunOnce/PlatformSettingsService.cs +++ b/ErsatzTV/Services/RunOnce/PlatformSettingsService.cs @@ -5,7 +5,6 @@ using ErsatzTV.Core.Domain; using ErsatzTV.Core.Interfaces.Repositories; using ErsatzTV.Core.Interfaces.Runtime; using ErsatzTV.Infrastructure.Data; -using LanguageExt; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; @@ -35,19 +34,7 @@ namespace ErsatzTV.Services.RunOnce { _logger.LogInformation("Disabling ffmpeg reports on Windows platform"); IConfigElementRepository repo = scope.ServiceProvider.GetRequiredService(); - ConfigElementKey key = ConfigElementKey.FFmpegSaveReports; - Option maybeExisting = await repo.Get(key); - await maybeExisting.Match( - ce => - { - ce.Value = false.ToString(); - return repo.Update(ce); - }, - () => - { - var ce = new ConfigElement { Key = key.Key, Value = false.ToString() }; - return repo.Add(ce); - }); + await repo.Upsert(ConfigElementKey.FFmpegSaveReports, false); } } diff --git a/ErsatzTV/Shared/MainLayout.razor b/ErsatzTV/Shared/MainLayout.razor index 1f3b2f389..a1c709933 100644 --- a/ErsatzTV/Shared/MainLayout.razor +++ b/ErsatzTV/Shared/MainLayout.razor @@ -28,7 +28,7 @@ M3U XMLTV - API + @* API *@ diff --git a/ErsatzTV/Startup.cs b/ErsatzTV/Startup.cs index d37028d68..88ca90d7c 100644 --- a/ErsatzTV/Startup.cs +++ b/ErsatzTV/Startup.cs @@ -52,7 +52,6 @@ using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.OpenApi.Models; using MudBlazor.Services; using Newtonsoft.Json; using Newtonsoft.Json.Converters; @@ -93,10 +92,6 @@ namespace ErsatzTV options.ImplicitlyValidateChildProperties = true; }); - services.AddSwaggerGen( - c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "ErsatzTV API", Version = "v1" }); }); - services.AddSwaggerGenNewtonsoftSupport(); - services.AddRazorPages(); services.AddServerSideBlazor(); @@ -170,10 +165,6 @@ namespace ErsatzTV { // app.UseSerilogRequestLogging(); - app.UseSwagger(); - app.UseSwaggerUI( - c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "ErsatzTV API"); }); - app.UseStaticFiles(); app.UseRouting(); @@ -204,10 +195,7 @@ namespace ErsatzTV services.AddScoped(); services.AddScoped(); services.AddScoped(); - services.AddScoped(); services.AddScoped(); - services.AddScoped(); - services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); diff --git a/generated/ErsatzTV.Api.Sdk/.openapi-generator-ignore b/generated/ErsatzTV.Api.Sdk/.openapi-generator-ignore deleted file mode 100644 index b86669310..000000000 --- a/generated/ErsatzTV.Api.Sdk/.openapi-generator-ignore +++ /dev/null @@ -1,5 +0,0 @@ -docs/** -git_push.sh -ErsatzTV.Api.Sdk.sln -.gitignore -README.md diff --git a/generated/ErsatzTV.Api.Sdk/.openapi-generator/FILES b/generated/ErsatzTV.Api.Sdk/.openapi-generator/FILES deleted file mode 100644 index bbda04b5f..000000000 --- a/generated/ErsatzTV.Api.Sdk/.openapi-generator/FILES +++ /dev/null @@ -1,100 +0,0 @@ -appveyor.yml -src/ErsatzTV.Api.Sdk.Test/Api/ChannelsApiTests.cs -src/ErsatzTV.Api.Sdk.Test/Api/FFmpegProfileApiTests.cs -src/ErsatzTV.Api.Sdk.Test/Api/MediaCollectionsApiTests.cs -src/ErsatzTV.Api.Sdk.Test/Api/MediaItemsApiTests.cs -src/ErsatzTV.Api.Sdk.Test/Api/MediaSourcesApiTests.cs -src/ErsatzTV.Api.Sdk.Test/Api/PlayoutApiTests.cs -src/ErsatzTV.Api.Sdk.Test/Api/ProgramScheduleApiTests.cs -src/ErsatzTV.Api.Sdk.Test/ErsatzTV.Api.Sdk.Test.csproj -src/ErsatzTV.Api.Sdk.Test/Model/AddProgramScheduleItemTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/ChannelViewModelTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/CreateChannelTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/CreateFFmpegProfileTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/CreatePlayoutTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/CreateProgramScheduleTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/CreateSimpleMediaCollectionTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/DeleteChannelTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/DeleteFFmpegProfileTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/DeletePlayoutTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/DeleteProgramScheduleTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/FFmpegProfileViewModelTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/MediaCollectionViewModelTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/MediaItemViewModelTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/MediaSourceTypeTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/MediaSourceViewModelTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/PlaybackOrderTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/PlayoutChannelViewModelTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/PlayoutModeTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/PlayoutProgramScheduleViewModelTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/PlayoutViewModelTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/ProblemDetailsTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/ProgramScheduleItemViewModelTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/ProgramSchedulePlayoutTypeTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/ProgramScheduleViewModelTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/ReplaceProgramScheduleItemTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/ResolutionViewModelTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/StartTypeTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/StreamingModeTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/UpdateChannelTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/UpdateFFmpegProfileTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/UpdatePlayoutTests.cs -src/ErsatzTV.Api.Sdk.Test/Model/UpdateProgramScheduleTests.cs -src/ErsatzTV.Api.Sdk/Api/ChannelsApi.cs -src/ErsatzTV.Api.Sdk/Api/FFmpegProfileApi.cs -src/ErsatzTV.Api.Sdk/Api/MediaCollectionsApi.cs -src/ErsatzTV.Api.Sdk/Api/MediaItemsApi.cs -src/ErsatzTV.Api.Sdk/Api/MediaSourcesApi.cs -src/ErsatzTV.Api.Sdk/Api/PlayoutApi.cs -src/ErsatzTV.Api.Sdk/Api/ProgramScheduleApi.cs -src/ErsatzTV.Api.Sdk/Client/ApiClient.cs -src/ErsatzTV.Api.Sdk/Client/ApiException.cs -src/ErsatzTV.Api.Sdk/Client/ApiResponse.cs -src/ErsatzTV.Api.Sdk/Client/ClientUtils.cs -src/ErsatzTV.Api.Sdk/Client/Configuration.cs -src/ErsatzTV.Api.Sdk/Client/ExceptionFactory.cs -src/ErsatzTV.Api.Sdk/Client/GlobalConfiguration.cs -src/ErsatzTV.Api.Sdk/Client/HttpMethod.cs -src/ErsatzTV.Api.Sdk/Client/IApiAccessor.cs -src/ErsatzTV.Api.Sdk/Client/IAsynchronousClient.cs -src/ErsatzTV.Api.Sdk/Client/IReadableConfiguration.cs -src/ErsatzTV.Api.Sdk/Client/ISynchronousClient.cs -src/ErsatzTV.Api.Sdk/Client/Multimap.cs -src/ErsatzTV.Api.Sdk/Client/OpenAPIDateConverter.cs -src/ErsatzTV.Api.Sdk/Client/RequestOptions.cs -src/ErsatzTV.Api.Sdk/Client/RetryConfiguration.cs -src/ErsatzTV.Api.Sdk/ErsatzTV.Api.Sdk.csproj -src/ErsatzTV.Api.Sdk/Model/AbstractOpenAPISchema.cs -src/ErsatzTV.Api.Sdk/Model/AddProgramScheduleItem.cs -src/ErsatzTV.Api.Sdk/Model/ChannelViewModel.cs -src/ErsatzTV.Api.Sdk/Model/CreateChannel.cs -src/ErsatzTV.Api.Sdk/Model/CreateFFmpegProfile.cs -src/ErsatzTV.Api.Sdk/Model/CreatePlayout.cs -src/ErsatzTV.Api.Sdk/Model/CreateProgramSchedule.cs -src/ErsatzTV.Api.Sdk/Model/CreateSimpleMediaCollection.cs -src/ErsatzTV.Api.Sdk/Model/DeleteChannel.cs -src/ErsatzTV.Api.Sdk/Model/DeleteFFmpegProfile.cs -src/ErsatzTV.Api.Sdk/Model/DeletePlayout.cs -src/ErsatzTV.Api.Sdk/Model/DeleteProgramSchedule.cs -src/ErsatzTV.Api.Sdk/Model/FFmpegProfileViewModel.cs -src/ErsatzTV.Api.Sdk/Model/MediaCollectionViewModel.cs -src/ErsatzTV.Api.Sdk/Model/MediaItemViewModel.cs -src/ErsatzTV.Api.Sdk/Model/MediaSourceType.cs -src/ErsatzTV.Api.Sdk/Model/MediaSourceViewModel.cs -src/ErsatzTV.Api.Sdk/Model/PlaybackOrder.cs -src/ErsatzTV.Api.Sdk/Model/PlayoutChannelViewModel.cs -src/ErsatzTV.Api.Sdk/Model/PlayoutMode.cs -src/ErsatzTV.Api.Sdk/Model/PlayoutProgramScheduleViewModel.cs -src/ErsatzTV.Api.Sdk/Model/PlayoutViewModel.cs -src/ErsatzTV.Api.Sdk/Model/ProblemDetails.cs -src/ErsatzTV.Api.Sdk/Model/ProgramScheduleItemViewModel.cs -src/ErsatzTV.Api.Sdk/Model/ProgramSchedulePlayoutType.cs -src/ErsatzTV.Api.Sdk/Model/ProgramScheduleViewModel.cs -src/ErsatzTV.Api.Sdk/Model/ReplaceProgramScheduleItem.cs -src/ErsatzTV.Api.Sdk/Model/ResolutionViewModel.cs -src/ErsatzTV.Api.Sdk/Model/StartType.cs -src/ErsatzTV.Api.Sdk/Model/StreamingMode.cs -src/ErsatzTV.Api.Sdk/Model/UpdateChannel.cs -src/ErsatzTV.Api.Sdk/Model/UpdateFFmpegProfile.cs -src/ErsatzTV.Api.Sdk/Model/UpdatePlayout.cs -src/ErsatzTV.Api.Sdk/Model/UpdateProgramSchedule.cs diff --git a/generated/ErsatzTV.Api.Sdk/.openapi-generator/VERSION b/generated/ErsatzTV.Api.Sdk/.openapi-generator/VERSION deleted file mode 100644 index 28cbf7c0a..000000000 --- a/generated/ErsatzTV.Api.Sdk/.openapi-generator/VERSION +++ /dev/null @@ -1 +0,0 @@ -5.0.0 \ No newline at end of file diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/ChannelsApi.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/ChannelsApi.cs deleted file mode 100644 index ad27b1526..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/ChannelsApi.cs +++ /dev/null @@ -1,935 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Net; -using System.Net.Mime; -using ErsatzTV.Api.Sdk.Client; -using ErsatzTV.Api.Sdk.Model; - -namespace ErsatzTV.Api.Sdk.Api -{ - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IChannelsApiSync : IApiAccessor - { - #region Synchronous Operations - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ChannelViewModel - ChannelViewModel ApiChannelsChannelIdGet(int channelId); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of ChannelViewModel - ApiResponse ApiChannelsChannelIdGetWithHttpInfo(int channelId); - /// - /// - /// - /// Thrown when fails to make API call - /// - /// - void ApiChannelsDelete(DeleteChannel deleteChannel); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of Object(void) - ApiResponse ApiChannelsDeleteWithHttpInfo(DeleteChannel deleteChannel); - /// - /// - /// - /// Thrown when fails to make API call - /// List<ChannelViewModel> - List ApiChannelsGet(); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// ApiResponse of List<ChannelViewModel> - ApiResponse> ApiChannelsGetWithHttpInfo(); - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ChannelViewModel - ChannelViewModel ApiChannelsPatch(UpdateChannel updateChannel); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of ChannelViewModel - ApiResponse ApiChannelsPatchWithHttpInfo(UpdateChannel updateChannel); - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ChannelViewModel - ChannelViewModel ApiChannelsPost(CreateChannel createChannel); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of ChannelViewModel - ApiResponse ApiChannelsPostWithHttpInfo(CreateChannel createChannel); - #endregion Synchronous Operations - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IChannelsApiAsync : IApiAccessor - { - #region Asynchronous Operations - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ChannelViewModel - System.Threading.Tasks.Task ApiChannelsChannelIdGetAsync(int channelId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ChannelViewModel) - System.Threading.Tasks.Task> ApiChannelsChannelIdGetWithHttpInfoAsync(int channelId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of void - System.Threading.Tasks.Task ApiChannelsDeleteAsync(DeleteChannel deleteChannel, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse - System.Threading.Tasks.Task> ApiChannelsDeleteWithHttpInfoAsync(DeleteChannel deleteChannel, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of List<ChannelViewModel> - System.Threading.Tasks.Task> ApiChannelsGetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<ChannelViewModel>) - System.Threading.Tasks.Task>> ApiChannelsGetWithHttpInfoAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ChannelViewModel - System.Threading.Tasks.Task ApiChannelsPatchAsync(UpdateChannel updateChannel, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ChannelViewModel) - System.Threading.Tasks.Task> ApiChannelsPatchWithHttpInfoAsync(UpdateChannel updateChannel, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ChannelViewModel - System.Threading.Tasks.Task ApiChannelsPostAsync(CreateChannel createChannel, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ChannelViewModel) - System.Threading.Tasks.Task> ApiChannelsPostWithHttpInfoAsync(CreateChannel createChannel, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - #endregion Asynchronous Operations - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IChannelsApi : IChannelsApiSync, IChannelsApiAsync - { - - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public partial class ChannelsApi : IChannelsApi - { - private ErsatzTV.Api.Sdk.Client.ExceptionFactory _exceptionFactory = (name, response) => null; - - /// - /// Initializes a new instance of the class. - /// - /// - public ChannelsApi() : this((string)null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// - public ChannelsApi(String basePath) - { - this.Configuration = ErsatzTV.Api.Sdk.Client.Configuration.MergeConfigurations( - ErsatzTV.Api.Sdk.Client.GlobalConfiguration.Instance, - new ErsatzTV.Api.Sdk.Client.Configuration { BasePath = basePath } - ); - this.Client = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - this.ExceptionFactory = ErsatzTV.Api.Sdk.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class - /// using Configuration object - /// - /// An instance of Configuration - /// - public ChannelsApi(ErsatzTV.Api.Sdk.Client.Configuration configuration) - { - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Configuration = ErsatzTV.Api.Sdk.Client.Configuration.MergeConfigurations( - ErsatzTV.Api.Sdk.Client.GlobalConfiguration.Instance, - configuration - ); - this.Client = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - ExceptionFactory = ErsatzTV.Api.Sdk.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class - /// using a Configuration object and client instance. - /// - /// The client interface for synchronous API access. - /// The client interface for asynchronous API access. - /// The configuration object. - public ChannelsApi(ErsatzTV.Api.Sdk.Client.ISynchronousClient client, ErsatzTV.Api.Sdk.Client.IAsynchronousClient asyncClient, ErsatzTV.Api.Sdk.Client.IReadableConfiguration configuration) - { - if (client == null) throw new ArgumentNullException("client"); - if (asyncClient == null) throw new ArgumentNullException("asyncClient"); - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Client = client; - this.AsynchronousClient = asyncClient; - this.Configuration = configuration; - this.ExceptionFactory = ErsatzTV.Api.Sdk.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// The client for accessing this underlying API asynchronously. - /// - public ErsatzTV.Api.Sdk.Client.IAsynchronousClient AsynchronousClient { get; set; } - - /// - /// The client for accessing this underlying API synchronously. - /// - public ErsatzTV.Api.Sdk.Client.ISynchronousClient Client { get; set; } - - /// - /// Gets the base path of the API client. - /// - /// The base path - public String GetBasePath() - { - return this.Configuration.BasePath; - } - - /// - /// Gets or sets the configuration object - /// - /// An instance of the Configuration - public ErsatzTV.Api.Sdk.Client.IReadableConfiguration Configuration { get; set; } - - /// - /// Provides a factory method hook for the creation of exceptions. - /// - public ErsatzTV.Api.Sdk.Client.ExceptionFactory ExceptionFactory - { - get - { - if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1) - { - throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported."); - } - return _exceptionFactory; - } - set { _exceptionFactory = value; } - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ChannelViewModel - public ChannelViewModel ApiChannelsChannelIdGet(int channelId) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = ApiChannelsChannelIdGetWithHttpInfo(channelId); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of ChannelViewModel - public ErsatzTV.Api.Sdk.Client.ApiResponse ApiChannelsChannelIdGetWithHttpInfo(int channelId) - { - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("channelId", ErsatzTV.Api.Sdk.Client.ClientUtils.ParameterToString(channelId)); // path parameter - - - // make the HTTP request - var localVarResponse = this.Client.Get("/api/channels/{channelId}", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiChannelsChannelIdGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ChannelViewModel - public async System.Threading.Tasks.Task ApiChannelsChannelIdGetAsync(int channelId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = await ApiChannelsChannelIdGetWithHttpInfoAsync(channelId, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ChannelViewModel) - public async System.Threading.Tasks.Task> ApiChannelsChannelIdGetWithHttpInfoAsync(int channelId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("channelId", ErsatzTV.Api.Sdk.Client.ClientUtils.ParameterToString(channelId)); // path parameter - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.GetAsync("/api/channels/{channelId}", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiChannelsChannelIdGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// - public void ApiChannelsDelete(DeleteChannel deleteChannel) - { - ApiChannelsDeleteWithHttpInfo(deleteChannel); - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of Object(void) - public ErsatzTV.Api.Sdk.Client.ApiResponse ApiChannelsDeleteWithHttpInfo(DeleteChannel deleteChannel) - { - // verify the required parameter 'deleteChannel' is set - if (deleteChannel == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'deleteChannel' when calling ChannelsApi->ApiChannelsDelete"); - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = deleteChannel; - - - // make the HTTP request - var localVarResponse = this.Client.Delete("/api/channels", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiChannelsDelete", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of void - public async System.Threading.Tasks.Task ApiChannelsDeleteAsync(DeleteChannel deleteChannel, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - await ApiChannelsDeleteWithHttpInfoAsync(deleteChannel, cancellationToken).ConfigureAwait(false); - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse - public async System.Threading.Tasks.Task> ApiChannelsDeleteWithHttpInfoAsync(DeleteChannel deleteChannel, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - // verify the required parameter 'deleteChannel' is set - if (deleteChannel == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'deleteChannel' when calling ChannelsApi->ApiChannelsDelete"); - - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = deleteChannel; - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.DeleteAsync("/api/channels", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiChannelsDelete", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// List<ChannelViewModel> - public List ApiChannelsGet() - { - ErsatzTV.Api.Sdk.Client.ApiResponse> localVarResponse = ApiChannelsGetWithHttpInfo(); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// ApiResponse of List<ChannelViewModel> - public ErsatzTV.Api.Sdk.Client.ApiResponse> ApiChannelsGetWithHttpInfo() - { - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - - - // make the HTTP request - var localVarResponse = this.Client.Get>("/api/channels", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiChannelsGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of List<ChannelViewModel> - public async System.Threading.Tasks.Task> ApiChannelsGetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse> localVarResponse = await ApiChannelsGetWithHttpInfoAsync(cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<ChannelViewModel>) - public async System.Threading.Tasks.Task>> ApiChannelsGetWithHttpInfoAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.GetAsync>("/api/channels", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiChannelsGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ChannelViewModel - public ChannelViewModel ApiChannelsPatch(UpdateChannel updateChannel) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = ApiChannelsPatchWithHttpInfo(updateChannel); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of ChannelViewModel - public ErsatzTV.Api.Sdk.Client.ApiResponse ApiChannelsPatchWithHttpInfo(UpdateChannel updateChannel) - { - // verify the required parameter 'updateChannel' is set - if (updateChannel == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'updateChannel' when calling ChannelsApi->ApiChannelsPatch"); - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = updateChannel; - - - // make the HTTP request - var localVarResponse = this.Client.Patch("/api/channels", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiChannelsPatch", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ChannelViewModel - public async System.Threading.Tasks.Task ApiChannelsPatchAsync(UpdateChannel updateChannel, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = await ApiChannelsPatchWithHttpInfoAsync(updateChannel, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ChannelViewModel) - public async System.Threading.Tasks.Task> ApiChannelsPatchWithHttpInfoAsync(UpdateChannel updateChannel, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - // verify the required parameter 'updateChannel' is set - if (updateChannel == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'updateChannel' when calling ChannelsApi->ApiChannelsPatch"); - - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = updateChannel; - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.PatchAsync("/api/channels", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiChannelsPatch", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ChannelViewModel - public ChannelViewModel ApiChannelsPost(CreateChannel createChannel) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = ApiChannelsPostWithHttpInfo(createChannel); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of ChannelViewModel - public ErsatzTV.Api.Sdk.Client.ApiResponse ApiChannelsPostWithHttpInfo(CreateChannel createChannel) - { - // verify the required parameter 'createChannel' is set - if (createChannel == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'createChannel' when calling ChannelsApi->ApiChannelsPost"); - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = createChannel; - - - // make the HTTP request - var localVarResponse = this.Client.Post("/api/channels", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiChannelsPost", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ChannelViewModel - public async System.Threading.Tasks.Task ApiChannelsPostAsync(CreateChannel createChannel, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = await ApiChannelsPostWithHttpInfoAsync(createChannel, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ChannelViewModel) - public async System.Threading.Tasks.Task> ApiChannelsPostWithHttpInfoAsync(CreateChannel createChannel, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - // verify the required parameter 'createChannel' is set - if (createChannel == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'createChannel' when calling ChannelsApi->ApiChannelsPost"); - - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = createChannel; - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.PostAsync("/api/channels", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiChannelsPost", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - } -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/FFmpegProfileApi.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/FFmpegProfileApi.cs deleted file mode 100644 index de8ff2da7..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/FFmpegProfileApi.cs +++ /dev/null @@ -1,935 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Net; -using System.Net.Mime; -using ErsatzTV.Api.Sdk.Client; -using ErsatzTV.Api.Sdk.Model; - -namespace ErsatzTV.Api.Sdk.Api -{ - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IFFmpegProfileApiSync : IApiAccessor - { - #region Synchronous Operations - /// - /// - /// - /// Thrown when fails to make API call - /// - /// - void ApiFfmpegProfilesDelete(DeleteFFmpegProfile deleteFFmpegProfile); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of Object(void) - ApiResponse ApiFfmpegProfilesDeleteWithHttpInfo(DeleteFFmpegProfile deleteFFmpegProfile); - /// - /// - /// - /// Thrown when fails to make API call - /// - /// FFmpegProfileViewModel - FFmpegProfileViewModel ApiFfmpegProfilesFfmpegProfileIdGet(int ffmpegProfileId); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of FFmpegProfileViewModel - ApiResponse ApiFfmpegProfilesFfmpegProfileIdGetWithHttpInfo(int ffmpegProfileId); - /// - /// - /// - /// Thrown when fails to make API call - /// List<FFmpegProfileViewModel> - List ApiFfmpegProfilesGet(); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// ApiResponse of List<FFmpegProfileViewModel> - ApiResponse> ApiFfmpegProfilesGetWithHttpInfo(); - /// - /// - /// - /// Thrown when fails to make API call - /// - /// FFmpegProfileViewModel - FFmpegProfileViewModel ApiFfmpegProfilesPatch(UpdateFFmpegProfile updateFFmpegProfile); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of FFmpegProfileViewModel - ApiResponse ApiFfmpegProfilesPatchWithHttpInfo(UpdateFFmpegProfile updateFFmpegProfile); - /// - /// - /// - /// Thrown when fails to make API call - /// - /// FFmpegProfileViewModel - FFmpegProfileViewModel ApiFfmpegProfilesPost(CreateFFmpegProfile createFFmpegProfile); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of FFmpegProfileViewModel - ApiResponse ApiFfmpegProfilesPostWithHttpInfo(CreateFFmpegProfile createFFmpegProfile); - #endregion Synchronous Operations - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IFFmpegProfileApiAsync : IApiAccessor - { - #region Asynchronous Operations - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of void - System.Threading.Tasks.Task ApiFfmpegProfilesDeleteAsync(DeleteFFmpegProfile deleteFFmpegProfile, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse - System.Threading.Tasks.Task> ApiFfmpegProfilesDeleteWithHttpInfoAsync(DeleteFFmpegProfile deleteFFmpegProfile, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of FFmpegProfileViewModel - System.Threading.Tasks.Task ApiFfmpegProfilesFfmpegProfileIdGetAsync(int ffmpegProfileId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (FFmpegProfileViewModel) - System.Threading.Tasks.Task> ApiFfmpegProfilesFfmpegProfileIdGetWithHttpInfoAsync(int ffmpegProfileId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of List<FFmpegProfileViewModel> - System.Threading.Tasks.Task> ApiFfmpegProfilesGetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<FFmpegProfileViewModel>) - System.Threading.Tasks.Task>> ApiFfmpegProfilesGetWithHttpInfoAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of FFmpegProfileViewModel - System.Threading.Tasks.Task ApiFfmpegProfilesPatchAsync(UpdateFFmpegProfile updateFFmpegProfile, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (FFmpegProfileViewModel) - System.Threading.Tasks.Task> ApiFfmpegProfilesPatchWithHttpInfoAsync(UpdateFFmpegProfile updateFFmpegProfile, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of FFmpegProfileViewModel - System.Threading.Tasks.Task ApiFfmpegProfilesPostAsync(CreateFFmpegProfile createFFmpegProfile, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (FFmpegProfileViewModel) - System.Threading.Tasks.Task> ApiFfmpegProfilesPostWithHttpInfoAsync(CreateFFmpegProfile createFFmpegProfile, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - #endregion Asynchronous Operations - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IFFmpegProfileApi : IFFmpegProfileApiSync, IFFmpegProfileApiAsync - { - - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public partial class FFmpegProfileApi : IFFmpegProfileApi - { - private ErsatzTV.Api.Sdk.Client.ExceptionFactory _exceptionFactory = (name, response) => null; - - /// - /// Initializes a new instance of the class. - /// - /// - public FFmpegProfileApi() : this((string)null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// - public FFmpegProfileApi(String basePath) - { - this.Configuration = ErsatzTV.Api.Sdk.Client.Configuration.MergeConfigurations( - ErsatzTV.Api.Sdk.Client.GlobalConfiguration.Instance, - new ErsatzTV.Api.Sdk.Client.Configuration { BasePath = basePath } - ); - this.Client = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - this.ExceptionFactory = ErsatzTV.Api.Sdk.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class - /// using Configuration object - /// - /// An instance of Configuration - /// - public FFmpegProfileApi(ErsatzTV.Api.Sdk.Client.Configuration configuration) - { - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Configuration = ErsatzTV.Api.Sdk.Client.Configuration.MergeConfigurations( - ErsatzTV.Api.Sdk.Client.GlobalConfiguration.Instance, - configuration - ); - this.Client = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - ExceptionFactory = ErsatzTV.Api.Sdk.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class - /// using a Configuration object and client instance. - /// - /// The client interface for synchronous API access. - /// The client interface for asynchronous API access. - /// The configuration object. - public FFmpegProfileApi(ErsatzTV.Api.Sdk.Client.ISynchronousClient client, ErsatzTV.Api.Sdk.Client.IAsynchronousClient asyncClient, ErsatzTV.Api.Sdk.Client.IReadableConfiguration configuration) - { - if (client == null) throw new ArgumentNullException("client"); - if (asyncClient == null) throw new ArgumentNullException("asyncClient"); - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Client = client; - this.AsynchronousClient = asyncClient; - this.Configuration = configuration; - this.ExceptionFactory = ErsatzTV.Api.Sdk.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// The client for accessing this underlying API asynchronously. - /// - public ErsatzTV.Api.Sdk.Client.IAsynchronousClient AsynchronousClient { get; set; } - - /// - /// The client for accessing this underlying API synchronously. - /// - public ErsatzTV.Api.Sdk.Client.ISynchronousClient Client { get; set; } - - /// - /// Gets the base path of the API client. - /// - /// The base path - public String GetBasePath() - { - return this.Configuration.BasePath; - } - - /// - /// Gets or sets the configuration object - /// - /// An instance of the Configuration - public ErsatzTV.Api.Sdk.Client.IReadableConfiguration Configuration { get; set; } - - /// - /// Provides a factory method hook for the creation of exceptions. - /// - public ErsatzTV.Api.Sdk.Client.ExceptionFactory ExceptionFactory - { - get - { - if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1) - { - throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported."); - } - return _exceptionFactory; - } - set { _exceptionFactory = value; } - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// - public void ApiFfmpegProfilesDelete(DeleteFFmpegProfile deleteFFmpegProfile) - { - ApiFfmpegProfilesDeleteWithHttpInfo(deleteFFmpegProfile); - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of Object(void) - public ErsatzTV.Api.Sdk.Client.ApiResponse ApiFfmpegProfilesDeleteWithHttpInfo(DeleteFFmpegProfile deleteFFmpegProfile) - { - // verify the required parameter 'deleteFFmpegProfile' is set - if (deleteFFmpegProfile == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'deleteFFmpegProfile' when calling FFmpegProfileApi->ApiFfmpegProfilesDelete"); - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = deleteFFmpegProfile; - - - // make the HTTP request - var localVarResponse = this.Client.Delete("/api/ffmpeg/profiles", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiFfmpegProfilesDelete", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of void - public async System.Threading.Tasks.Task ApiFfmpegProfilesDeleteAsync(DeleteFFmpegProfile deleteFFmpegProfile, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - await ApiFfmpegProfilesDeleteWithHttpInfoAsync(deleteFFmpegProfile, cancellationToken).ConfigureAwait(false); - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse - public async System.Threading.Tasks.Task> ApiFfmpegProfilesDeleteWithHttpInfoAsync(DeleteFFmpegProfile deleteFFmpegProfile, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - // verify the required parameter 'deleteFFmpegProfile' is set - if (deleteFFmpegProfile == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'deleteFFmpegProfile' when calling FFmpegProfileApi->ApiFfmpegProfilesDelete"); - - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = deleteFFmpegProfile; - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.DeleteAsync("/api/ffmpeg/profiles", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiFfmpegProfilesDelete", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// FFmpegProfileViewModel - public FFmpegProfileViewModel ApiFfmpegProfilesFfmpegProfileIdGet(int ffmpegProfileId) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = ApiFfmpegProfilesFfmpegProfileIdGetWithHttpInfo(ffmpegProfileId); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of FFmpegProfileViewModel - public ErsatzTV.Api.Sdk.Client.ApiResponse ApiFfmpegProfilesFfmpegProfileIdGetWithHttpInfo(int ffmpegProfileId) - { - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("ffmpegProfileId", ErsatzTV.Api.Sdk.Client.ClientUtils.ParameterToString(ffmpegProfileId)); // path parameter - - - // make the HTTP request - var localVarResponse = this.Client.Get("/api/ffmpeg/profiles/{ffmpegProfileId}", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiFfmpegProfilesFfmpegProfileIdGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of FFmpegProfileViewModel - public async System.Threading.Tasks.Task ApiFfmpegProfilesFfmpegProfileIdGetAsync(int ffmpegProfileId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = await ApiFfmpegProfilesFfmpegProfileIdGetWithHttpInfoAsync(ffmpegProfileId, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (FFmpegProfileViewModel) - public async System.Threading.Tasks.Task> ApiFfmpegProfilesFfmpegProfileIdGetWithHttpInfoAsync(int ffmpegProfileId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("ffmpegProfileId", ErsatzTV.Api.Sdk.Client.ClientUtils.ParameterToString(ffmpegProfileId)); // path parameter - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.GetAsync("/api/ffmpeg/profiles/{ffmpegProfileId}", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiFfmpegProfilesFfmpegProfileIdGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// List<FFmpegProfileViewModel> - public List ApiFfmpegProfilesGet() - { - ErsatzTV.Api.Sdk.Client.ApiResponse> localVarResponse = ApiFfmpegProfilesGetWithHttpInfo(); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// ApiResponse of List<FFmpegProfileViewModel> - public ErsatzTV.Api.Sdk.Client.ApiResponse> ApiFfmpegProfilesGetWithHttpInfo() - { - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - - - // make the HTTP request - var localVarResponse = this.Client.Get>("/api/ffmpeg/profiles", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiFfmpegProfilesGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of List<FFmpegProfileViewModel> - public async System.Threading.Tasks.Task> ApiFfmpegProfilesGetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse> localVarResponse = await ApiFfmpegProfilesGetWithHttpInfoAsync(cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<FFmpegProfileViewModel>) - public async System.Threading.Tasks.Task>> ApiFfmpegProfilesGetWithHttpInfoAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.GetAsync>("/api/ffmpeg/profiles", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiFfmpegProfilesGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// FFmpegProfileViewModel - public FFmpegProfileViewModel ApiFfmpegProfilesPatch(UpdateFFmpegProfile updateFFmpegProfile) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = ApiFfmpegProfilesPatchWithHttpInfo(updateFFmpegProfile); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of FFmpegProfileViewModel - public ErsatzTV.Api.Sdk.Client.ApiResponse ApiFfmpegProfilesPatchWithHttpInfo(UpdateFFmpegProfile updateFFmpegProfile) - { - // verify the required parameter 'updateFFmpegProfile' is set - if (updateFFmpegProfile == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'updateFFmpegProfile' when calling FFmpegProfileApi->ApiFfmpegProfilesPatch"); - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = updateFFmpegProfile; - - - // make the HTTP request - var localVarResponse = this.Client.Patch("/api/ffmpeg/profiles", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiFfmpegProfilesPatch", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of FFmpegProfileViewModel - public async System.Threading.Tasks.Task ApiFfmpegProfilesPatchAsync(UpdateFFmpegProfile updateFFmpegProfile, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = await ApiFfmpegProfilesPatchWithHttpInfoAsync(updateFFmpegProfile, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (FFmpegProfileViewModel) - public async System.Threading.Tasks.Task> ApiFfmpegProfilesPatchWithHttpInfoAsync(UpdateFFmpegProfile updateFFmpegProfile, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - // verify the required parameter 'updateFFmpegProfile' is set - if (updateFFmpegProfile == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'updateFFmpegProfile' when calling FFmpegProfileApi->ApiFfmpegProfilesPatch"); - - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = updateFFmpegProfile; - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.PatchAsync("/api/ffmpeg/profiles", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiFfmpegProfilesPatch", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// FFmpegProfileViewModel - public FFmpegProfileViewModel ApiFfmpegProfilesPost(CreateFFmpegProfile createFFmpegProfile) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = ApiFfmpegProfilesPostWithHttpInfo(createFFmpegProfile); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of FFmpegProfileViewModel - public ErsatzTV.Api.Sdk.Client.ApiResponse ApiFfmpegProfilesPostWithHttpInfo(CreateFFmpegProfile createFFmpegProfile) - { - // verify the required parameter 'createFFmpegProfile' is set - if (createFFmpegProfile == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'createFFmpegProfile' when calling FFmpegProfileApi->ApiFfmpegProfilesPost"); - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = createFFmpegProfile; - - - // make the HTTP request - var localVarResponse = this.Client.Post("/api/ffmpeg/profiles", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiFfmpegProfilesPost", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of FFmpegProfileViewModel - public async System.Threading.Tasks.Task ApiFfmpegProfilesPostAsync(CreateFFmpegProfile createFFmpegProfile, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = await ApiFfmpegProfilesPostWithHttpInfoAsync(createFFmpegProfile, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (FFmpegProfileViewModel) - public async System.Threading.Tasks.Task> ApiFfmpegProfilesPostWithHttpInfoAsync(CreateFFmpegProfile createFFmpegProfile, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - // verify the required parameter 'createFFmpegProfile' is set - if (createFFmpegProfile == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'createFFmpegProfile' when calling FFmpegProfileApi->ApiFfmpegProfilesPost"); - - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = createFFmpegProfile; - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.PostAsync("/api/ffmpeg/profiles", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiFfmpegProfilesPost", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - } -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/MediaCollectionsApi.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/MediaCollectionsApi.cs deleted file mode 100644 index 59d66e095..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/MediaCollectionsApi.cs +++ /dev/null @@ -1,931 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Net; -using System.Net.Mime; -using ErsatzTV.Api.Sdk.Client; -using ErsatzTV.Api.Sdk.Model; - -namespace ErsatzTV.Api.Sdk.Api -{ - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IMediaCollectionsApiSync : IApiAccessor - { - #region Synchronous Operations - /// - /// - /// - /// Thrown when fails to make API call - /// List<MediaCollectionViewModel> - List ApiMediaCollectionsGet(); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// ApiResponse of List<MediaCollectionViewModel> - ApiResponse> ApiMediaCollectionsGetWithHttpInfo(); - /// - /// - /// - /// Thrown when fails to make API call - /// - /// MediaCollectionViewModel - MediaCollectionViewModel ApiMediaCollectionsIdGet(int id); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of MediaCollectionViewModel - ApiResponse ApiMediaCollectionsIdGetWithHttpInfo(int id); - /// - /// - /// - /// Thrown when fails to make API call - /// - /// List<MediaItemViewModel> - List ApiMediaCollectionsIdItemsGet(int id); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of List<MediaItemViewModel> - ApiResponse> ApiMediaCollectionsIdItemsGetWithHttpInfo(int id); - /// - /// - /// - /// Thrown when fails to make API call - /// - /// - /// List<MediaItemViewModel> - List ApiMediaCollectionsIdItemsPut(int id, List requestBody); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// - /// ApiResponse of List<MediaItemViewModel> - ApiResponse> ApiMediaCollectionsIdItemsPutWithHttpInfo(int id, List requestBody); - /// - /// - /// - /// Thrown when fails to make API call - /// - /// MediaCollectionViewModel - MediaCollectionViewModel ApiMediaCollectionsPost(CreateSimpleMediaCollection createSimpleMediaCollection); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of MediaCollectionViewModel - ApiResponse ApiMediaCollectionsPostWithHttpInfo(CreateSimpleMediaCollection createSimpleMediaCollection); - #endregion Synchronous Operations - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IMediaCollectionsApiAsync : IApiAccessor - { - #region Asynchronous Operations - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of List<MediaCollectionViewModel> - System.Threading.Tasks.Task> ApiMediaCollectionsGetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<MediaCollectionViewModel>) - System.Threading.Tasks.Task>> ApiMediaCollectionsGetWithHttpInfoAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of MediaCollectionViewModel - System.Threading.Tasks.Task ApiMediaCollectionsIdGetAsync(int id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (MediaCollectionViewModel) - System.Threading.Tasks.Task> ApiMediaCollectionsIdGetWithHttpInfoAsync(int id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of List<MediaItemViewModel> - System.Threading.Tasks.Task> ApiMediaCollectionsIdItemsGetAsync(int id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<MediaItemViewModel>) - System.Threading.Tasks.Task>> ApiMediaCollectionsIdItemsGetWithHttpInfoAsync(int id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// - /// Cancellation Token to cancel the request. - /// Task of List<MediaItemViewModel> - System.Threading.Tasks.Task> ApiMediaCollectionsIdItemsPutAsync(int id, List requestBody, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<MediaItemViewModel>) - System.Threading.Tasks.Task>> ApiMediaCollectionsIdItemsPutWithHttpInfoAsync(int id, List requestBody, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of MediaCollectionViewModel - System.Threading.Tasks.Task ApiMediaCollectionsPostAsync(CreateSimpleMediaCollection createSimpleMediaCollection, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (MediaCollectionViewModel) - System.Threading.Tasks.Task> ApiMediaCollectionsPostWithHttpInfoAsync(CreateSimpleMediaCollection createSimpleMediaCollection, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - #endregion Asynchronous Operations - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IMediaCollectionsApi : IMediaCollectionsApiSync, IMediaCollectionsApiAsync - { - - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public partial class MediaCollectionsApi : IMediaCollectionsApi - { - private ErsatzTV.Api.Sdk.Client.ExceptionFactory _exceptionFactory = (name, response) => null; - - /// - /// Initializes a new instance of the class. - /// - /// - public MediaCollectionsApi() : this((string)null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// - public MediaCollectionsApi(String basePath) - { - this.Configuration = ErsatzTV.Api.Sdk.Client.Configuration.MergeConfigurations( - ErsatzTV.Api.Sdk.Client.GlobalConfiguration.Instance, - new ErsatzTV.Api.Sdk.Client.Configuration { BasePath = basePath } - ); - this.Client = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - this.ExceptionFactory = ErsatzTV.Api.Sdk.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class - /// using Configuration object - /// - /// An instance of Configuration - /// - public MediaCollectionsApi(ErsatzTV.Api.Sdk.Client.Configuration configuration) - { - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Configuration = ErsatzTV.Api.Sdk.Client.Configuration.MergeConfigurations( - ErsatzTV.Api.Sdk.Client.GlobalConfiguration.Instance, - configuration - ); - this.Client = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - ExceptionFactory = ErsatzTV.Api.Sdk.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class - /// using a Configuration object and client instance. - /// - /// The client interface for synchronous API access. - /// The client interface for asynchronous API access. - /// The configuration object. - public MediaCollectionsApi(ErsatzTV.Api.Sdk.Client.ISynchronousClient client, ErsatzTV.Api.Sdk.Client.IAsynchronousClient asyncClient, ErsatzTV.Api.Sdk.Client.IReadableConfiguration configuration) - { - if (client == null) throw new ArgumentNullException("client"); - if (asyncClient == null) throw new ArgumentNullException("asyncClient"); - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Client = client; - this.AsynchronousClient = asyncClient; - this.Configuration = configuration; - this.ExceptionFactory = ErsatzTV.Api.Sdk.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// The client for accessing this underlying API asynchronously. - /// - public ErsatzTV.Api.Sdk.Client.IAsynchronousClient AsynchronousClient { get; set; } - - /// - /// The client for accessing this underlying API synchronously. - /// - public ErsatzTV.Api.Sdk.Client.ISynchronousClient Client { get; set; } - - /// - /// Gets the base path of the API client. - /// - /// The base path - public String GetBasePath() - { - return this.Configuration.BasePath; - } - - /// - /// Gets or sets the configuration object - /// - /// An instance of the Configuration - public ErsatzTV.Api.Sdk.Client.IReadableConfiguration Configuration { get; set; } - - /// - /// Provides a factory method hook for the creation of exceptions. - /// - public ErsatzTV.Api.Sdk.Client.ExceptionFactory ExceptionFactory - { - get - { - if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1) - { - throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported."); - } - return _exceptionFactory; - } - set { _exceptionFactory = value; } - } - - /// - /// - /// - /// Thrown when fails to make API call - /// List<MediaCollectionViewModel> - public List ApiMediaCollectionsGet() - { - ErsatzTV.Api.Sdk.Client.ApiResponse> localVarResponse = ApiMediaCollectionsGetWithHttpInfo(); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// ApiResponse of List<MediaCollectionViewModel> - public ErsatzTV.Api.Sdk.Client.ApiResponse> ApiMediaCollectionsGetWithHttpInfo() - { - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - - - // make the HTTP request - var localVarResponse = this.Client.Get>("/api/media/collections", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiMediaCollectionsGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of List<MediaCollectionViewModel> - public async System.Threading.Tasks.Task> ApiMediaCollectionsGetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse> localVarResponse = await ApiMediaCollectionsGetWithHttpInfoAsync(cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<MediaCollectionViewModel>) - public async System.Threading.Tasks.Task>> ApiMediaCollectionsGetWithHttpInfoAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.GetAsync>("/api/media/collections", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiMediaCollectionsGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// MediaCollectionViewModel - public MediaCollectionViewModel ApiMediaCollectionsIdGet(int id) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = ApiMediaCollectionsIdGetWithHttpInfo(id); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of MediaCollectionViewModel - public ErsatzTV.Api.Sdk.Client.ApiResponse ApiMediaCollectionsIdGetWithHttpInfo(int id) - { - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("id", ErsatzTV.Api.Sdk.Client.ClientUtils.ParameterToString(id)); // path parameter - - - // make the HTTP request - var localVarResponse = this.Client.Get("/api/media/collections/{id}", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiMediaCollectionsIdGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of MediaCollectionViewModel - public async System.Threading.Tasks.Task ApiMediaCollectionsIdGetAsync(int id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = await ApiMediaCollectionsIdGetWithHttpInfoAsync(id, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (MediaCollectionViewModel) - public async System.Threading.Tasks.Task> ApiMediaCollectionsIdGetWithHttpInfoAsync(int id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("id", ErsatzTV.Api.Sdk.Client.ClientUtils.ParameterToString(id)); // path parameter - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.GetAsync("/api/media/collections/{id}", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiMediaCollectionsIdGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// List<MediaItemViewModel> - public List ApiMediaCollectionsIdItemsGet(int id) - { - ErsatzTV.Api.Sdk.Client.ApiResponse> localVarResponse = ApiMediaCollectionsIdItemsGetWithHttpInfo(id); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of List<MediaItemViewModel> - public ErsatzTV.Api.Sdk.Client.ApiResponse> ApiMediaCollectionsIdItemsGetWithHttpInfo(int id) - { - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("id", ErsatzTV.Api.Sdk.Client.ClientUtils.ParameterToString(id)); // path parameter - - - // make the HTTP request - var localVarResponse = this.Client.Get>("/api/media/collections/{id}/items", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiMediaCollectionsIdItemsGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of List<MediaItemViewModel> - public async System.Threading.Tasks.Task> ApiMediaCollectionsIdItemsGetAsync(int id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse> localVarResponse = await ApiMediaCollectionsIdItemsGetWithHttpInfoAsync(id, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<MediaItemViewModel>) - public async System.Threading.Tasks.Task>> ApiMediaCollectionsIdItemsGetWithHttpInfoAsync(int id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("id", ErsatzTV.Api.Sdk.Client.ClientUtils.ParameterToString(id)); // path parameter - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.GetAsync>("/api/media/collections/{id}/items", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiMediaCollectionsIdItemsGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// - /// List<MediaItemViewModel> - public List ApiMediaCollectionsIdItemsPut(int id, List requestBody) - { - ErsatzTV.Api.Sdk.Client.ApiResponse> localVarResponse = ApiMediaCollectionsIdItemsPutWithHttpInfo(id, requestBody); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// - /// ApiResponse of List<MediaItemViewModel> - public ErsatzTV.Api.Sdk.Client.ApiResponse> ApiMediaCollectionsIdItemsPutWithHttpInfo(int id, List requestBody) - { - // verify the required parameter 'requestBody' is set - if (requestBody == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'requestBody' when calling MediaCollectionsApi->ApiMediaCollectionsIdItemsPut"); - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("id", ErsatzTV.Api.Sdk.Client.ClientUtils.ParameterToString(id)); // path parameter - localVarRequestOptions.Data = requestBody; - - - // make the HTTP request - var localVarResponse = this.Client.Put>("/api/media/collections/{id}/items", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiMediaCollectionsIdItemsPut", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// - /// Cancellation Token to cancel the request. - /// Task of List<MediaItemViewModel> - public async System.Threading.Tasks.Task> ApiMediaCollectionsIdItemsPutAsync(int id, List requestBody, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse> localVarResponse = await ApiMediaCollectionsIdItemsPutWithHttpInfoAsync(id, requestBody, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<MediaItemViewModel>) - public async System.Threading.Tasks.Task>> ApiMediaCollectionsIdItemsPutWithHttpInfoAsync(int id, List requestBody, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - // verify the required parameter 'requestBody' is set - if (requestBody == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'requestBody' when calling MediaCollectionsApi->ApiMediaCollectionsIdItemsPut"); - - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("id", ErsatzTV.Api.Sdk.Client.ClientUtils.ParameterToString(id)); // path parameter - localVarRequestOptions.Data = requestBody; - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.PutAsync>("/api/media/collections/{id}/items", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiMediaCollectionsIdItemsPut", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// MediaCollectionViewModel - public MediaCollectionViewModel ApiMediaCollectionsPost(CreateSimpleMediaCollection createSimpleMediaCollection) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = ApiMediaCollectionsPostWithHttpInfo(createSimpleMediaCollection); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of MediaCollectionViewModel - public ErsatzTV.Api.Sdk.Client.ApiResponse ApiMediaCollectionsPostWithHttpInfo(CreateSimpleMediaCollection createSimpleMediaCollection) - { - // verify the required parameter 'createSimpleMediaCollection' is set - if (createSimpleMediaCollection == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'createSimpleMediaCollection' when calling MediaCollectionsApi->ApiMediaCollectionsPost"); - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = createSimpleMediaCollection; - - - // make the HTTP request - var localVarResponse = this.Client.Post("/api/media/collections", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiMediaCollectionsPost", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of MediaCollectionViewModel - public async System.Threading.Tasks.Task ApiMediaCollectionsPostAsync(CreateSimpleMediaCollection createSimpleMediaCollection, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = await ApiMediaCollectionsPostWithHttpInfoAsync(createSimpleMediaCollection, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (MediaCollectionViewModel) - public async System.Threading.Tasks.Task> ApiMediaCollectionsPostWithHttpInfoAsync(CreateSimpleMediaCollection createSimpleMediaCollection, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - // verify the required parameter 'createSimpleMediaCollection' is set - if (createSimpleMediaCollection == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'createSimpleMediaCollection' when calling MediaCollectionsApi->ApiMediaCollectionsPost"); - - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = createSimpleMediaCollection; - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.PostAsync("/api/media/collections", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiMediaCollectionsPost", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - } -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/MediaItemsApi.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/MediaItemsApi.cs deleted file mode 100644 index 183fd4638..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/MediaItemsApi.cs +++ /dev/null @@ -1,445 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Net; -using System.Net.Mime; -using ErsatzTV.Api.Sdk.Client; -using ErsatzTV.Api.Sdk.Model; - -namespace ErsatzTV.Api.Sdk.Api -{ - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IMediaItemsApiSync : IApiAccessor - { - #region Synchronous Operations - /// - /// - /// - /// Thrown when fails to make API call - /// List<MediaItemViewModel> - List ApiMediaItemsGet(); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// ApiResponse of List<MediaItemViewModel> - ApiResponse> ApiMediaItemsGetWithHttpInfo(); - /// - /// - /// - /// Thrown when fails to make API call - /// - /// MediaItemViewModel - MediaItemViewModel ApiMediaItemsMediaItemIdGet(int mediaItemId); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of MediaItemViewModel - ApiResponse ApiMediaItemsMediaItemIdGetWithHttpInfo(int mediaItemId); - #endregion Synchronous Operations - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IMediaItemsApiAsync : IApiAccessor - { - #region Asynchronous Operations - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of List<MediaItemViewModel> - System.Threading.Tasks.Task> ApiMediaItemsGetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<MediaItemViewModel>) - System.Threading.Tasks.Task>> ApiMediaItemsGetWithHttpInfoAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of MediaItemViewModel - System.Threading.Tasks.Task ApiMediaItemsMediaItemIdGetAsync(int mediaItemId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (MediaItemViewModel) - System.Threading.Tasks.Task> ApiMediaItemsMediaItemIdGetWithHttpInfoAsync(int mediaItemId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - #endregion Asynchronous Operations - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IMediaItemsApi : IMediaItemsApiSync, IMediaItemsApiAsync - { - - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public partial class MediaItemsApi : IMediaItemsApi - { - private ErsatzTV.Api.Sdk.Client.ExceptionFactory _exceptionFactory = (name, response) => null; - - /// - /// Initializes a new instance of the class. - /// - /// - public MediaItemsApi() : this((string)null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// - public MediaItemsApi(String basePath) - { - this.Configuration = ErsatzTV.Api.Sdk.Client.Configuration.MergeConfigurations( - ErsatzTV.Api.Sdk.Client.GlobalConfiguration.Instance, - new ErsatzTV.Api.Sdk.Client.Configuration { BasePath = basePath } - ); - this.Client = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - this.ExceptionFactory = ErsatzTV.Api.Sdk.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class - /// using Configuration object - /// - /// An instance of Configuration - /// - public MediaItemsApi(ErsatzTV.Api.Sdk.Client.Configuration configuration) - { - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Configuration = ErsatzTV.Api.Sdk.Client.Configuration.MergeConfigurations( - ErsatzTV.Api.Sdk.Client.GlobalConfiguration.Instance, - configuration - ); - this.Client = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - ExceptionFactory = ErsatzTV.Api.Sdk.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class - /// using a Configuration object and client instance. - /// - /// The client interface for synchronous API access. - /// The client interface for asynchronous API access. - /// The configuration object. - public MediaItemsApi(ErsatzTV.Api.Sdk.Client.ISynchronousClient client, ErsatzTV.Api.Sdk.Client.IAsynchronousClient asyncClient, ErsatzTV.Api.Sdk.Client.IReadableConfiguration configuration) - { - if (client == null) throw new ArgumentNullException("client"); - if (asyncClient == null) throw new ArgumentNullException("asyncClient"); - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Client = client; - this.AsynchronousClient = asyncClient; - this.Configuration = configuration; - this.ExceptionFactory = ErsatzTV.Api.Sdk.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// The client for accessing this underlying API asynchronously. - /// - public ErsatzTV.Api.Sdk.Client.IAsynchronousClient AsynchronousClient { get; set; } - - /// - /// The client for accessing this underlying API synchronously. - /// - public ErsatzTV.Api.Sdk.Client.ISynchronousClient Client { get; set; } - - /// - /// Gets the base path of the API client. - /// - /// The base path - public String GetBasePath() - { - return this.Configuration.BasePath; - } - - /// - /// Gets or sets the configuration object - /// - /// An instance of the Configuration - public ErsatzTV.Api.Sdk.Client.IReadableConfiguration Configuration { get; set; } - - /// - /// Provides a factory method hook for the creation of exceptions. - /// - public ErsatzTV.Api.Sdk.Client.ExceptionFactory ExceptionFactory - { - get - { - if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1) - { - throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported."); - } - return _exceptionFactory; - } - set { _exceptionFactory = value; } - } - - /// - /// - /// - /// Thrown when fails to make API call - /// List<MediaItemViewModel> - public List ApiMediaItemsGet() - { - ErsatzTV.Api.Sdk.Client.ApiResponse> localVarResponse = ApiMediaItemsGetWithHttpInfo(); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// ApiResponse of List<MediaItemViewModel> - public ErsatzTV.Api.Sdk.Client.ApiResponse> ApiMediaItemsGetWithHttpInfo() - { - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - - - // make the HTTP request - var localVarResponse = this.Client.Get>("/api/media/items", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiMediaItemsGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of List<MediaItemViewModel> - public async System.Threading.Tasks.Task> ApiMediaItemsGetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse> localVarResponse = await ApiMediaItemsGetWithHttpInfoAsync(cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<MediaItemViewModel>) - public async System.Threading.Tasks.Task>> ApiMediaItemsGetWithHttpInfoAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.GetAsync>("/api/media/items", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiMediaItemsGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// MediaItemViewModel - public MediaItemViewModel ApiMediaItemsMediaItemIdGet(int mediaItemId) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = ApiMediaItemsMediaItemIdGetWithHttpInfo(mediaItemId); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of MediaItemViewModel - public ErsatzTV.Api.Sdk.Client.ApiResponse ApiMediaItemsMediaItemIdGetWithHttpInfo(int mediaItemId) - { - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("mediaItemId", ErsatzTV.Api.Sdk.Client.ClientUtils.ParameterToString(mediaItemId)); // path parameter - - - // make the HTTP request - var localVarResponse = this.Client.Get("/api/media/items/{mediaItemId}", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiMediaItemsMediaItemIdGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of MediaItemViewModel - public async System.Threading.Tasks.Task ApiMediaItemsMediaItemIdGetAsync(int mediaItemId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = await ApiMediaItemsMediaItemIdGetWithHttpInfoAsync(mediaItemId, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (MediaItemViewModel) - public async System.Threading.Tasks.Task> ApiMediaItemsMediaItemIdGetWithHttpInfoAsync(int mediaItemId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("mediaItemId", ErsatzTV.Api.Sdk.Client.ClientUtils.ParameterToString(mediaItemId)); // path parameter - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.GetAsync("/api/media/items/{mediaItemId}", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiMediaItemsMediaItemIdGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - } -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/MediaSourcesApi.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/MediaSourcesApi.cs deleted file mode 100644 index ffc5bee06..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/MediaSourcesApi.cs +++ /dev/null @@ -1,445 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Net; -using System.Net.Mime; -using ErsatzTV.Api.Sdk.Client; -using ErsatzTV.Api.Sdk.Model; - -namespace ErsatzTV.Api.Sdk.Api -{ - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IMediaSourcesApiSync : IApiAccessor - { - #region Synchronous Operations - /// - /// - /// - /// Thrown when fails to make API call - /// List<MediaSourceViewModel> - List ApiMediaSourcesGet(); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// ApiResponse of List<MediaSourceViewModel> - ApiResponse> ApiMediaSourcesGetWithHttpInfo(); - /// - /// - /// - /// Thrown when fails to make API call - /// - /// MediaSourceViewModel - MediaSourceViewModel ApiMediaSourcesIdGet(int id); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of MediaSourceViewModel - ApiResponse ApiMediaSourcesIdGetWithHttpInfo(int id); - #endregion Synchronous Operations - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IMediaSourcesApiAsync : IApiAccessor - { - #region Asynchronous Operations - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of List<MediaSourceViewModel> - System.Threading.Tasks.Task> ApiMediaSourcesGetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<MediaSourceViewModel>) - System.Threading.Tasks.Task>> ApiMediaSourcesGetWithHttpInfoAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of MediaSourceViewModel - System.Threading.Tasks.Task ApiMediaSourcesIdGetAsync(int id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (MediaSourceViewModel) - System.Threading.Tasks.Task> ApiMediaSourcesIdGetWithHttpInfoAsync(int id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - #endregion Asynchronous Operations - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IMediaSourcesApi : IMediaSourcesApiSync, IMediaSourcesApiAsync - { - - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public partial class MediaSourcesApi : IMediaSourcesApi - { - private ErsatzTV.Api.Sdk.Client.ExceptionFactory _exceptionFactory = (name, response) => null; - - /// - /// Initializes a new instance of the class. - /// - /// - public MediaSourcesApi() : this((string)null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// - public MediaSourcesApi(String basePath) - { - this.Configuration = ErsatzTV.Api.Sdk.Client.Configuration.MergeConfigurations( - ErsatzTV.Api.Sdk.Client.GlobalConfiguration.Instance, - new ErsatzTV.Api.Sdk.Client.Configuration { BasePath = basePath } - ); - this.Client = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - this.ExceptionFactory = ErsatzTV.Api.Sdk.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class - /// using Configuration object - /// - /// An instance of Configuration - /// - public MediaSourcesApi(ErsatzTV.Api.Sdk.Client.Configuration configuration) - { - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Configuration = ErsatzTV.Api.Sdk.Client.Configuration.MergeConfigurations( - ErsatzTV.Api.Sdk.Client.GlobalConfiguration.Instance, - configuration - ); - this.Client = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - ExceptionFactory = ErsatzTV.Api.Sdk.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class - /// using a Configuration object and client instance. - /// - /// The client interface for synchronous API access. - /// The client interface for asynchronous API access. - /// The configuration object. - public MediaSourcesApi(ErsatzTV.Api.Sdk.Client.ISynchronousClient client, ErsatzTV.Api.Sdk.Client.IAsynchronousClient asyncClient, ErsatzTV.Api.Sdk.Client.IReadableConfiguration configuration) - { - if (client == null) throw new ArgumentNullException("client"); - if (asyncClient == null) throw new ArgumentNullException("asyncClient"); - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Client = client; - this.AsynchronousClient = asyncClient; - this.Configuration = configuration; - this.ExceptionFactory = ErsatzTV.Api.Sdk.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// The client for accessing this underlying API asynchronously. - /// - public ErsatzTV.Api.Sdk.Client.IAsynchronousClient AsynchronousClient { get; set; } - - /// - /// The client for accessing this underlying API synchronously. - /// - public ErsatzTV.Api.Sdk.Client.ISynchronousClient Client { get; set; } - - /// - /// Gets the base path of the API client. - /// - /// The base path - public String GetBasePath() - { - return this.Configuration.BasePath; - } - - /// - /// Gets or sets the configuration object - /// - /// An instance of the Configuration - public ErsatzTV.Api.Sdk.Client.IReadableConfiguration Configuration { get; set; } - - /// - /// Provides a factory method hook for the creation of exceptions. - /// - public ErsatzTV.Api.Sdk.Client.ExceptionFactory ExceptionFactory - { - get - { - if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1) - { - throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported."); - } - return _exceptionFactory; - } - set { _exceptionFactory = value; } - } - - /// - /// - /// - /// Thrown when fails to make API call - /// List<MediaSourceViewModel> - public List ApiMediaSourcesGet() - { - ErsatzTV.Api.Sdk.Client.ApiResponse> localVarResponse = ApiMediaSourcesGetWithHttpInfo(); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// ApiResponse of List<MediaSourceViewModel> - public ErsatzTV.Api.Sdk.Client.ApiResponse> ApiMediaSourcesGetWithHttpInfo() - { - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - - - // make the HTTP request - var localVarResponse = this.Client.Get>("/api/media/sources", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiMediaSourcesGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of List<MediaSourceViewModel> - public async System.Threading.Tasks.Task> ApiMediaSourcesGetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse> localVarResponse = await ApiMediaSourcesGetWithHttpInfoAsync(cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<MediaSourceViewModel>) - public async System.Threading.Tasks.Task>> ApiMediaSourcesGetWithHttpInfoAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.GetAsync>("/api/media/sources", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiMediaSourcesGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// MediaSourceViewModel - public MediaSourceViewModel ApiMediaSourcesIdGet(int id) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = ApiMediaSourcesIdGetWithHttpInfo(id); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of MediaSourceViewModel - public ErsatzTV.Api.Sdk.Client.ApiResponse ApiMediaSourcesIdGetWithHttpInfo(int id) - { - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("id", ErsatzTV.Api.Sdk.Client.ClientUtils.ParameterToString(id)); // path parameter - - - // make the HTTP request - var localVarResponse = this.Client.Get("/api/media/sources/{id}", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiMediaSourcesIdGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of MediaSourceViewModel - public async System.Threading.Tasks.Task ApiMediaSourcesIdGetAsync(int id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = await ApiMediaSourcesIdGetWithHttpInfoAsync(id, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (MediaSourceViewModel) - public async System.Threading.Tasks.Task> ApiMediaSourcesIdGetWithHttpInfoAsync(int id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("id", ErsatzTV.Api.Sdk.Client.ClientUtils.ParameterToString(id)); // path parameter - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.GetAsync("/api/media/sources/{id}", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiMediaSourcesIdGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - } -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/PlayoutApi.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/PlayoutApi.cs deleted file mode 100644 index 18e1ddcc1..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/PlayoutApi.cs +++ /dev/null @@ -1,935 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Net; -using System.Net.Mime; -using ErsatzTV.Api.Sdk.Client; -using ErsatzTV.Api.Sdk.Model; - -namespace ErsatzTV.Api.Sdk.Api -{ - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IPlayoutApiSync : IApiAccessor - { - #region Synchronous Operations - /// - /// - /// - /// Thrown when fails to make API call - /// - /// - void ApiPlayoutsDelete(DeletePlayout deletePlayout); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of Object(void) - ApiResponse ApiPlayoutsDeleteWithHttpInfo(DeletePlayout deletePlayout); - /// - /// - /// - /// Thrown when fails to make API call - /// List<PlayoutViewModel> - List ApiPlayoutsGet(); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// ApiResponse of List<PlayoutViewModel> - ApiResponse> ApiPlayoutsGetWithHttpInfo(); - /// - /// - /// - /// Thrown when fails to make API call - /// - /// PlayoutViewModel - PlayoutViewModel ApiPlayoutsPatch(UpdatePlayout updatePlayout); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of PlayoutViewModel - ApiResponse ApiPlayoutsPatchWithHttpInfo(UpdatePlayout updatePlayout); - /// - /// - /// - /// Thrown when fails to make API call - /// - /// PlayoutViewModel - PlayoutViewModel ApiPlayoutsPlayoutIdGet(int playoutId); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of PlayoutViewModel - ApiResponse ApiPlayoutsPlayoutIdGetWithHttpInfo(int playoutId); - /// - /// - /// - /// Thrown when fails to make API call - /// - /// PlayoutViewModel - PlayoutViewModel ApiPlayoutsPost(CreatePlayout createPlayout); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of PlayoutViewModel - ApiResponse ApiPlayoutsPostWithHttpInfo(CreatePlayout createPlayout); - #endregion Synchronous Operations - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IPlayoutApiAsync : IApiAccessor - { - #region Asynchronous Operations - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of void - System.Threading.Tasks.Task ApiPlayoutsDeleteAsync(DeletePlayout deletePlayout, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse - System.Threading.Tasks.Task> ApiPlayoutsDeleteWithHttpInfoAsync(DeletePlayout deletePlayout, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of List<PlayoutViewModel> - System.Threading.Tasks.Task> ApiPlayoutsGetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<PlayoutViewModel>) - System.Threading.Tasks.Task>> ApiPlayoutsGetWithHttpInfoAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of PlayoutViewModel - System.Threading.Tasks.Task ApiPlayoutsPatchAsync(UpdatePlayout updatePlayout, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (PlayoutViewModel) - System.Threading.Tasks.Task> ApiPlayoutsPatchWithHttpInfoAsync(UpdatePlayout updatePlayout, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of PlayoutViewModel - System.Threading.Tasks.Task ApiPlayoutsPlayoutIdGetAsync(int playoutId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (PlayoutViewModel) - System.Threading.Tasks.Task> ApiPlayoutsPlayoutIdGetWithHttpInfoAsync(int playoutId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of PlayoutViewModel - System.Threading.Tasks.Task ApiPlayoutsPostAsync(CreatePlayout createPlayout, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (PlayoutViewModel) - System.Threading.Tasks.Task> ApiPlayoutsPostWithHttpInfoAsync(CreatePlayout createPlayout, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - #endregion Asynchronous Operations - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IPlayoutApi : IPlayoutApiSync, IPlayoutApiAsync - { - - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public partial class PlayoutApi : IPlayoutApi - { - private ErsatzTV.Api.Sdk.Client.ExceptionFactory _exceptionFactory = (name, response) => null; - - /// - /// Initializes a new instance of the class. - /// - /// - public PlayoutApi() : this((string)null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// - public PlayoutApi(String basePath) - { - this.Configuration = ErsatzTV.Api.Sdk.Client.Configuration.MergeConfigurations( - ErsatzTV.Api.Sdk.Client.GlobalConfiguration.Instance, - new ErsatzTV.Api.Sdk.Client.Configuration { BasePath = basePath } - ); - this.Client = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - this.ExceptionFactory = ErsatzTV.Api.Sdk.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class - /// using Configuration object - /// - /// An instance of Configuration - /// - public PlayoutApi(ErsatzTV.Api.Sdk.Client.Configuration configuration) - { - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Configuration = ErsatzTV.Api.Sdk.Client.Configuration.MergeConfigurations( - ErsatzTV.Api.Sdk.Client.GlobalConfiguration.Instance, - configuration - ); - this.Client = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - ExceptionFactory = ErsatzTV.Api.Sdk.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class - /// using a Configuration object and client instance. - /// - /// The client interface for synchronous API access. - /// The client interface for asynchronous API access. - /// The configuration object. - public PlayoutApi(ErsatzTV.Api.Sdk.Client.ISynchronousClient client, ErsatzTV.Api.Sdk.Client.IAsynchronousClient asyncClient, ErsatzTV.Api.Sdk.Client.IReadableConfiguration configuration) - { - if (client == null) throw new ArgumentNullException("client"); - if (asyncClient == null) throw new ArgumentNullException("asyncClient"); - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Client = client; - this.AsynchronousClient = asyncClient; - this.Configuration = configuration; - this.ExceptionFactory = ErsatzTV.Api.Sdk.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// The client for accessing this underlying API asynchronously. - /// - public ErsatzTV.Api.Sdk.Client.IAsynchronousClient AsynchronousClient { get; set; } - - /// - /// The client for accessing this underlying API synchronously. - /// - public ErsatzTV.Api.Sdk.Client.ISynchronousClient Client { get; set; } - - /// - /// Gets the base path of the API client. - /// - /// The base path - public String GetBasePath() - { - return this.Configuration.BasePath; - } - - /// - /// Gets or sets the configuration object - /// - /// An instance of the Configuration - public ErsatzTV.Api.Sdk.Client.IReadableConfiguration Configuration { get; set; } - - /// - /// Provides a factory method hook for the creation of exceptions. - /// - public ErsatzTV.Api.Sdk.Client.ExceptionFactory ExceptionFactory - { - get - { - if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1) - { - throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported."); - } - return _exceptionFactory; - } - set { _exceptionFactory = value; } - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// - public void ApiPlayoutsDelete(DeletePlayout deletePlayout) - { - ApiPlayoutsDeleteWithHttpInfo(deletePlayout); - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of Object(void) - public ErsatzTV.Api.Sdk.Client.ApiResponse ApiPlayoutsDeleteWithHttpInfo(DeletePlayout deletePlayout) - { - // verify the required parameter 'deletePlayout' is set - if (deletePlayout == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'deletePlayout' when calling PlayoutApi->ApiPlayoutsDelete"); - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = deletePlayout; - - - // make the HTTP request - var localVarResponse = this.Client.Delete("/api/playouts", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiPlayoutsDelete", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of void - public async System.Threading.Tasks.Task ApiPlayoutsDeleteAsync(DeletePlayout deletePlayout, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - await ApiPlayoutsDeleteWithHttpInfoAsync(deletePlayout, cancellationToken).ConfigureAwait(false); - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse - public async System.Threading.Tasks.Task> ApiPlayoutsDeleteWithHttpInfoAsync(DeletePlayout deletePlayout, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - // verify the required parameter 'deletePlayout' is set - if (deletePlayout == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'deletePlayout' when calling PlayoutApi->ApiPlayoutsDelete"); - - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = deletePlayout; - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.DeleteAsync("/api/playouts", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiPlayoutsDelete", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// List<PlayoutViewModel> - public List ApiPlayoutsGet() - { - ErsatzTV.Api.Sdk.Client.ApiResponse> localVarResponse = ApiPlayoutsGetWithHttpInfo(); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// ApiResponse of List<PlayoutViewModel> - public ErsatzTV.Api.Sdk.Client.ApiResponse> ApiPlayoutsGetWithHttpInfo() - { - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - - - // make the HTTP request - var localVarResponse = this.Client.Get>("/api/playouts", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiPlayoutsGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of List<PlayoutViewModel> - public async System.Threading.Tasks.Task> ApiPlayoutsGetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse> localVarResponse = await ApiPlayoutsGetWithHttpInfoAsync(cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<PlayoutViewModel>) - public async System.Threading.Tasks.Task>> ApiPlayoutsGetWithHttpInfoAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.GetAsync>("/api/playouts", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiPlayoutsGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// PlayoutViewModel - public PlayoutViewModel ApiPlayoutsPatch(UpdatePlayout updatePlayout) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = ApiPlayoutsPatchWithHttpInfo(updatePlayout); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of PlayoutViewModel - public ErsatzTV.Api.Sdk.Client.ApiResponse ApiPlayoutsPatchWithHttpInfo(UpdatePlayout updatePlayout) - { - // verify the required parameter 'updatePlayout' is set - if (updatePlayout == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'updatePlayout' when calling PlayoutApi->ApiPlayoutsPatch"); - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = updatePlayout; - - - // make the HTTP request - var localVarResponse = this.Client.Patch("/api/playouts", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiPlayoutsPatch", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of PlayoutViewModel - public async System.Threading.Tasks.Task ApiPlayoutsPatchAsync(UpdatePlayout updatePlayout, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = await ApiPlayoutsPatchWithHttpInfoAsync(updatePlayout, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (PlayoutViewModel) - public async System.Threading.Tasks.Task> ApiPlayoutsPatchWithHttpInfoAsync(UpdatePlayout updatePlayout, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - // verify the required parameter 'updatePlayout' is set - if (updatePlayout == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'updatePlayout' when calling PlayoutApi->ApiPlayoutsPatch"); - - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = updatePlayout; - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.PatchAsync("/api/playouts", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiPlayoutsPatch", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// PlayoutViewModel - public PlayoutViewModel ApiPlayoutsPlayoutIdGet(int playoutId) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = ApiPlayoutsPlayoutIdGetWithHttpInfo(playoutId); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of PlayoutViewModel - public ErsatzTV.Api.Sdk.Client.ApiResponse ApiPlayoutsPlayoutIdGetWithHttpInfo(int playoutId) - { - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("playoutId", ErsatzTV.Api.Sdk.Client.ClientUtils.ParameterToString(playoutId)); // path parameter - - - // make the HTTP request - var localVarResponse = this.Client.Get("/api/playouts/{playoutId}", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiPlayoutsPlayoutIdGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of PlayoutViewModel - public async System.Threading.Tasks.Task ApiPlayoutsPlayoutIdGetAsync(int playoutId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = await ApiPlayoutsPlayoutIdGetWithHttpInfoAsync(playoutId, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (PlayoutViewModel) - public async System.Threading.Tasks.Task> ApiPlayoutsPlayoutIdGetWithHttpInfoAsync(int playoutId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("playoutId", ErsatzTV.Api.Sdk.Client.ClientUtils.ParameterToString(playoutId)); // path parameter - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.GetAsync("/api/playouts/{playoutId}", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiPlayoutsPlayoutIdGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// PlayoutViewModel - public PlayoutViewModel ApiPlayoutsPost(CreatePlayout createPlayout) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = ApiPlayoutsPostWithHttpInfo(createPlayout); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of PlayoutViewModel - public ErsatzTV.Api.Sdk.Client.ApiResponse ApiPlayoutsPostWithHttpInfo(CreatePlayout createPlayout) - { - // verify the required parameter 'createPlayout' is set - if (createPlayout == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'createPlayout' when calling PlayoutApi->ApiPlayoutsPost"); - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = createPlayout; - - - // make the HTTP request - var localVarResponse = this.Client.Post("/api/playouts", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiPlayoutsPost", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of PlayoutViewModel - public async System.Threading.Tasks.Task ApiPlayoutsPostAsync(CreatePlayout createPlayout, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = await ApiPlayoutsPostWithHttpInfoAsync(createPlayout, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (PlayoutViewModel) - public async System.Threading.Tasks.Task> ApiPlayoutsPostWithHttpInfoAsync(CreatePlayout createPlayout, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - // verify the required parameter 'createPlayout' is set - if (createPlayout == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'createPlayout' when calling PlayoutApi->ApiPlayoutsPost"); - - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = createPlayout; - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.PostAsync("/api/playouts", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiPlayoutsPost", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - } -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/ProgramScheduleApi.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/ProgramScheduleApi.cs deleted file mode 100644 index d9f059312..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Api/ProgramScheduleApi.cs +++ /dev/null @@ -1,1569 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Net; -using System.Net.Mime; -using ErsatzTV.Api.Sdk.Client; -using ErsatzTV.Api.Sdk.Model; - -namespace ErsatzTV.Api.Sdk.Api -{ - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IProgramScheduleApiSync : IApiAccessor - { - #region Synchronous Operations - /// - /// - /// - /// Thrown when fails to make API call - /// - /// - void ApiSchedulesDelete(DeleteProgramSchedule deleteProgramSchedule); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of Object(void) - ApiResponse ApiSchedulesDeleteWithHttpInfo(DeleteProgramSchedule deleteProgramSchedule); - /// - /// - /// - /// Thrown when fails to make API call - /// List<ProgramScheduleViewModel> - List ApiSchedulesGet(); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// ApiResponse of List<ProgramScheduleViewModel> - ApiResponse> ApiSchedulesGetWithHttpInfo(); - /// - /// - /// - /// Thrown when fails to make API call - /// - /// List<ProgramScheduleItemViewModel> - List ApiSchedulesItemsAddPost(AddProgramScheduleItem addProgramScheduleItem); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of List<ProgramScheduleItemViewModel> - ApiResponse> ApiSchedulesItemsAddPostWithHttpInfo(AddProgramScheduleItem addProgramScheduleItem); - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ProgramScheduleViewModel - ProgramScheduleViewModel ApiSchedulesPatch(UpdateProgramSchedule updateProgramSchedule); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of ProgramScheduleViewModel - ApiResponse ApiSchedulesPatchWithHttpInfo(UpdateProgramSchedule updateProgramSchedule); - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ProgramScheduleViewModel - ProgramScheduleViewModel ApiSchedulesPost(CreateProgramSchedule createProgramSchedule); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of ProgramScheduleViewModel - ApiResponse ApiSchedulesPostWithHttpInfo(CreateProgramSchedule createProgramSchedule); - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ProgramScheduleViewModel - ProgramScheduleViewModel ApiSchedulesProgramScheduleIdGet(int programScheduleId); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of ProgramScheduleViewModel - ApiResponse ApiSchedulesProgramScheduleIdGetWithHttpInfo(int programScheduleId); - /// - /// - /// - /// Thrown when fails to make API call - /// - /// List<ProgramScheduleItemViewModel> - List ApiSchedulesProgramScheduleIdItemsDelete(int programScheduleId); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of List<ProgramScheduleItemViewModel> - ApiResponse> ApiSchedulesProgramScheduleIdItemsDeleteWithHttpInfo(int programScheduleId); - /// - /// - /// - /// Thrown when fails to make API call - /// - /// List<ProgramScheduleItemViewModel> - List ApiSchedulesProgramScheduleIdItemsGet(int programScheduleId); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of List<ProgramScheduleItemViewModel> - ApiResponse> ApiSchedulesProgramScheduleIdItemsGetWithHttpInfo(int programScheduleId); - /// - /// - /// - /// Thrown when fails to make API call - /// - /// - /// List<ProgramScheduleItemViewModel> - List ApiSchedulesProgramScheduleIdItemsPut(int programScheduleId, List replaceProgramScheduleItem); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// - /// ApiResponse of List<ProgramScheduleItemViewModel> - ApiResponse> ApiSchedulesProgramScheduleIdItemsPutWithHttpInfo(int programScheduleId, List replaceProgramScheduleItem); - #endregion Synchronous Operations - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IProgramScheduleApiAsync : IApiAccessor - { - #region Asynchronous Operations - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of void - System.Threading.Tasks.Task ApiSchedulesDeleteAsync(DeleteProgramSchedule deleteProgramSchedule, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse - System.Threading.Tasks.Task> ApiSchedulesDeleteWithHttpInfoAsync(DeleteProgramSchedule deleteProgramSchedule, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of List<ProgramScheduleViewModel> - System.Threading.Tasks.Task> ApiSchedulesGetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<ProgramScheduleViewModel>) - System.Threading.Tasks.Task>> ApiSchedulesGetWithHttpInfoAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of List<ProgramScheduleItemViewModel> - System.Threading.Tasks.Task> ApiSchedulesItemsAddPostAsync(AddProgramScheduleItem addProgramScheduleItem, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<ProgramScheduleItemViewModel>) - System.Threading.Tasks.Task>> ApiSchedulesItemsAddPostWithHttpInfoAsync(AddProgramScheduleItem addProgramScheduleItem, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ProgramScheduleViewModel - System.Threading.Tasks.Task ApiSchedulesPatchAsync(UpdateProgramSchedule updateProgramSchedule, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ProgramScheduleViewModel) - System.Threading.Tasks.Task> ApiSchedulesPatchWithHttpInfoAsync(UpdateProgramSchedule updateProgramSchedule, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ProgramScheduleViewModel - System.Threading.Tasks.Task ApiSchedulesPostAsync(CreateProgramSchedule createProgramSchedule, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ProgramScheduleViewModel) - System.Threading.Tasks.Task> ApiSchedulesPostWithHttpInfoAsync(CreateProgramSchedule createProgramSchedule, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ProgramScheduleViewModel - System.Threading.Tasks.Task ApiSchedulesProgramScheduleIdGetAsync(int programScheduleId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ProgramScheduleViewModel) - System.Threading.Tasks.Task> ApiSchedulesProgramScheduleIdGetWithHttpInfoAsync(int programScheduleId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of List<ProgramScheduleItemViewModel> - System.Threading.Tasks.Task> ApiSchedulesProgramScheduleIdItemsDeleteAsync(int programScheduleId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<ProgramScheduleItemViewModel>) - System.Threading.Tasks.Task>> ApiSchedulesProgramScheduleIdItemsDeleteWithHttpInfoAsync(int programScheduleId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of List<ProgramScheduleItemViewModel> - System.Threading.Tasks.Task> ApiSchedulesProgramScheduleIdItemsGetAsync(int programScheduleId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<ProgramScheduleItemViewModel>) - System.Threading.Tasks.Task>> ApiSchedulesProgramScheduleIdItemsGetWithHttpInfoAsync(int programScheduleId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// - /// Cancellation Token to cancel the request. - /// Task of List<ProgramScheduleItemViewModel> - System.Threading.Tasks.Task> ApiSchedulesProgramScheduleIdItemsPutAsync(int programScheduleId, List replaceProgramScheduleItem, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// - /// - /// - /// - /// - /// Thrown when fails to make API call - /// - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<ProgramScheduleItemViewModel>) - System.Threading.Tasks.Task>> ApiSchedulesProgramScheduleIdItemsPutWithHttpInfoAsync(int programScheduleId, List replaceProgramScheduleItem, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - #endregion Asynchronous Operations - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public interface IProgramScheduleApi : IProgramScheduleApiSync, IProgramScheduleApiAsync - { - - } - - /// - /// Represents a collection of functions to interact with the API endpoints - /// - public partial class ProgramScheduleApi : IProgramScheduleApi - { - private ErsatzTV.Api.Sdk.Client.ExceptionFactory _exceptionFactory = (name, response) => null; - - /// - /// Initializes a new instance of the class. - /// - /// - public ProgramScheduleApi() : this((string)null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// - public ProgramScheduleApi(String basePath) - { - this.Configuration = ErsatzTV.Api.Sdk.Client.Configuration.MergeConfigurations( - ErsatzTV.Api.Sdk.Client.GlobalConfiguration.Instance, - new ErsatzTV.Api.Sdk.Client.Configuration { BasePath = basePath } - ); - this.Client = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - this.ExceptionFactory = ErsatzTV.Api.Sdk.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class - /// using Configuration object - /// - /// An instance of Configuration - /// - public ProgramScheduleApi(ErsatzTV.Api.Sdk.Client.Configuration configuration) - { - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Configuration = ErsatzTV.Api.Sdk.Client.Configuration.MergeConfigurations( - ErsatzTV.Api.Sdk.Client.GlobalConfiguration.Instance, - configuration - ); - this.Client = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - this.AsynchronousClient = new ErsatzTV.Api.Sdk.Client.ApiClient(this.Configuration.BasePath); - ExceptionFactory = ErsatzTV.Api.Sdk.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class - /// using a Configuration object and client instance. - /// - /// The client interface for synchronous API access. - /// The client interface for asynchronous API access. - /// The configuration object. - public ProgramScheduleApi(ErsatzTV.Api.Sdk.Client.ISynchronousClient client, ErsatzTV.Api.Sdk.Client.IAsynchronousClient asyncClient, ErsatzTV.Api.Sdk.Client.IReadableConfiguration configuration) - { - if (client == null) throw new ArgumentNullException("client"); - if (asyncClient == null) throw new ArgumentNullException("asyncClient"); - if (configuration == null) throw new ArgumentNullException("configuration"); - - this.Client = client; - this.AsynchronousClient = asyncClient; - this.Configuration = configuration; - this.ExceptionFactory = ErsatzTV.Api.Sdk.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// The client for accessing this underlying API asynchronously. - /// - public ErsatzTV.Api.Sdk.Client.IAsynchronousClient AsynchronousClient { get; set; } - - /// - /// The client for accessing this underlying API synchronously. - /// - public ErsatzTV.Api.Sdk.Client.ISynchronousClient Client { get; set; } - - /// - /// Gets the base path of the API client. - /// - /// The base path - public String GetBasePath() - { - return this.Configuration.BasePath; - } - - /// - /// Gets or sets the configuration object - /// - /// An instance of the Configuration - public ErsatzTV.Api.Sdk.Client.IReadableConfiguration Configuration { get; set; } - - /// - /// Provides a factory method hook for the creation of exceptions. - /// - public ErsatzTV.Api.Sdk.Client.ExceptionFactory ExceptionFactory - { - get - { - if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1) - { - throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported."); - } - return _exceptionFactory; - } - set { _exceptionFactory = value; } - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// - public void ApiSchedulesDelete(DeleteProgramSchedule deleteProgramSchedule) - { - ApiSchedulesDeleteWithHttpInfo(deleteProgramSchedule); - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of Object(void) - public ErsatzTV.Api.Sdk.Client.ApiResponse ApiSchedulesDeleteWithHttpInfo(DeleteProgramSchedule deleteProgramSchedule) - { - // verify the required parameter 'deleteProgramSchedule' is set - if (deleteProgramSchedule == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'deleteProgramSchedule' when calling ProgramScheduleApi->ApiSchedulesDelete"); - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = deleteProgramSchedule; - - - // make the HTTP request - var localVarResponse = this.Client.Delete("/api/schedules", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiSchedulesDelete", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of void - public async System.Threading.Tasks.Task ApiSchedulesDeleteAsync(DeleteProgramSchedule deleteProgramSchedule, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - await ApiSchedulesDeleteWithHttpInfoAsync(deleteProgramSchedule, cancellationToken).ConfigureAwait(false); - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse - public async System.Threading.Tasks.Task> ApiSchedulesDeleteWithHttpInfoAsync(DeleteProgramSchedule deleteProgramSchedule, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - // verify the required parameter 'deleteProgramSchedule' is set - if (deleteProgramSchedule == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'deleteProgramSchedule' when calling ProgramScheduleApi->ApiSchedulesDelete"); - - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = deleteProgramSchedule; - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.DeleteAsync("/api/schedules", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiSchedulesDelete", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// List<ProgramScheduleViewModel> - public List ApiSchedulesGet() - { - ErsatzTV.Api.Sdk.Client.ApiResponse> localVarResponse = ApiSchedulesGetWithHttpInfo(); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// ApiResponse of List<ProgramScheduleViewModel> - public ErsatzTV.Api.Sdk.Client.ApiResponse> ApiSchedulesGetWithHttpInfo() - { - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - - - // make the HTTP request - var localVarResponse = this.Client.Get>("/api/schedules", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiSchedulesGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of List<ProgramScheduleViewModel> - public async System.Threading.Tasks.Task> ApiSchedulesGetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse> localVarResponse = await ApiSchedulesGetWithHttpInfoAsync(cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<ProgramScheduleViewModel>) - public async System.Threading.Tasks.Task>> ApiSchedulesGetWithHttpInfoAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.GetAsync>("/api/schedules", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiSchedulesGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// List<ProgramScheduleItemViewModel> - public List ApiSchedulesItemsAddPost(AddProgramScheduleItem addProgramScheduleItem) - { - ErsatzTV.Api.Sdk.Client.ApiResponse> localVarResponse = ApiSchedulesItemsAddPostWithHttpInfo(addProgramScheduleItem); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of List<ProgramScheduleItemViewModel> - public ErsatzTV.Api.Sdk.Client.ApiResponse> ApiSchedulesItemsAddPostWithHttpInfo(AddProgramScheduleItem addProgramScheduleItem) - { - // verify the required parameter 'addProgramScheduleItem' is set - if (addProgramScheduleItem == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'addProgramScheduleItem' when calling ProgramScheduleApi->ApiSchedulesItemsAddPost"); - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = addProgramScheduleItem; - - - // make the HTTP request - var localVarResponse = this.Client.Post>("/api/schedules/items/add", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiSchedulesItemsAddPost", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of List<ProgramScheduleItemViewModel> - public async System.Threading.Tasks.Task> ApiSchedulesItemsAddPostAsync(AddProgramScheduleItem addProgramScheduleItem, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse> localVarResponse = await ApiSchedulesItemsAddPostWithHttpInfoAsync(addProgramScheduleItem, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<ProgramScheduleItemViewModel>) - public async System.Threading.Tasks.Task>> ApiSchedulesItemsAddPostWithHttpInfoAsync(AddProgramScheduleItem addProgramScheduleItem, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - // verify the required parameter 'addProgramScheduleItem' is set - if (addProgramScheduleItem == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'addProgramScheduleItem' when calling ProgramScheduleApi->ApiSchedulesItemsAddPost"); - - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = addProgramScheduleItem; - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.PostAsync>("/api/schedules/items/add", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiSchedulesItemsAddPost", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ProgramScheduleViewModel - public ProgramScheduleViewModel ApiSchedulesPatch(UpdateProgramSchedule updateProgramSchedule) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = ApiSchedulesPatchWithHttpInfo(updateProgramSchedule); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of ProgramScheduleViewModel - public ErsatzTV.Api.Sdk.Client.ApiResponse ApiSchedulesPatchWithHttpInfo(UpdateProgramSchedule updateProgramSchedule) - { - // verify the required parameter 'updateProgramSchedule' is set - if (updateProgramSchedule == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'updateProgramSchedule' when calling ProgramScheduleApi->ApiSchedulesPatch"); - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = updateProgramSchedule; - - - // make the HTTP request - var localVarResponse = this.Client.Patch("/api/schedules", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiSchedulesPatch", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ProgramScheduleViewModel - public async System.Threading.Tasks.Task ApiSchedulesPatchAsync(UpdateProgramSchedule updateProgramSchedule, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = await ApiSchedulesPatchWithHttpInfoAsync(updateProgramSchedule, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ProgramScheduleViewModel) - public async System.Threading.Tasks.Task> ApiSchedulesPatchWithHttpInfoAsync(UpdateProgramSchedule updateProgramSchedule, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - // verify the required parameter 'updateProgramSchedule' is set - if (updateProgramSchedule == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'updateProgramSchedule' when calling ProgramScheduleApi->ApiSchedulesPatch"); - - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = updateProgramSchedule; - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.PatchAsync("/api/schedules", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiSchedulesPatch", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ProgramScheduleViewModel - public ProgramScheduleViewModel ApiSchedulesPost(CreateProgramSchedule createProgramSchedule) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = ApiSchedulesPostWithHttpInfo(createProgramSchedule); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of ProgramScheduleViewModel - public ErsatzTV.Api.Sdk.Client.ApiResponse ApiSchedulesPostWithHttpInfo(CreateProgramSchedule createProgramSchedule) - { - // verify the required parameter 'createProgramSchedule' is set - if (createProgramSchedule == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'createProgramSchedule' when calling ProgramScheduleApi->ApiSchedulesPost"); - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = createProgramSchedule; - - - // make the HTTP request - var localVarResponse = this.Client.Post("/api/schedules", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiSchedulesPost", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ProgramScheduleViewModel - public async System.Threading.Tasks.Task ApiSchedulesPostAsync(CreateProgramSchedule createProgramSchedule, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = await ApiSchedulesPostWithHttpInfoAsync(createProgramSchedule, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ProgramScheduleViewModel) - public async System.Threading.Tasks.Task> ApiSchedulesPostWithHttpInfoAsync(CreateProgramSchedule createProgramSchedule, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - // verify the required parameter 'createProgramSchedule' is set - if (createProgramSchedule == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'createProgramSchedule' when calling ProgramScheduleApi->ApiSchedulesPost"); - - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = createProgramSchedule; - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.PostAsync("/api/schedules", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiSchedulesPost", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ProgramScheduleViewModel - public ProgramScheduleViewModel ApiSchedulesProgramScheduleIdGet(int programScheduleId) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = ApiSchedulesProgramScheduleIdGetWithHttpInfo(programScheduleId); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of ProgramScheduleViewModel - public ErsatzTV.Api.Sdk.Client.ApiResponse ApiSchedulesProgramScheduleIdGetWithHttpInfo(int programScheduleId) - { - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("programScheduleId", ErsatzTV.Api.Sdk.Client.ClientUtils.ParameterToString(programScheduleId)); // path parameter - - - // make the HTTP request - var localVarResponse = this.Client.Get("/api/schedules/{programScheduleId}", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiSchedulesProgramScheduleIdGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ProgramScheduleViewModel - public async System.Threading.Tasks.Task ApiSchedulesProgramScheduleIdGetAsync(int programScheduleId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse localVarResponse = await ApiSchedulesProgramScheduleIdGetWithHttpInfoAsync(programScheduleId, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ProgramScheduleViewModel) - public async System.Threading.Tasks.Task> ApiSchedulesProgramScheduleIdGetWithHttpInfoAsync(int programScheduleId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("programScheduleId", ErsatzTV.Api.Sdk.Client.ClientUtils.ParameterToString(programScheduleId)); // path parameter - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.GetAsync("/api/schedules/{programScheduleId}", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiSchedulesProgramScheduleIdGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// List<ProgramScheduleItemViewModel> - public List ApiSchedulesProgramScheduleIdItemsDelete(int programScheduleId) - { - ErsatzTV.Api.Sdk.Client.ApiResponse> localVarResponse = ApiSchedulesProgramScheduleIdItemsDeleteWithHttpInfo(programScheduleId); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of List<ProgramScheduleItemViewModel> - public ErsatzTV.Api.Sdk.Client.ApiResponse> ApiSchedulesProgramScheduleIdItemsDeleteWithHttpInfo(int programScheduleId) - { - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("programScheduleId", ErsatzTV.Api.Sdk.Client.ClientUtils.ParameterToString(programScheduleId)); // path parameter - - - // make the HTTP request - var localVarResponse = this.Client.Delete>("/api/schedules/{programScheduleId}/items", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiSchedulesProgramScheduleIdItemsDelete", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of List<ProgramScheduleItemViewModel> - public async System.Threading.Tasks.Task> ApiSchedulesProgramScheduleIdItemsDeleteAsync(int programScheduleId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse> localVarResponse = await ApiSchedulesProgramScheduleIdItemsDeleteWithHttpInfoAsync(programScheduleId, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<ProgramScheduleItemViewModel>) - public async System.Threading.Tasks.Task>> ApiSchedulesProgramScheduleIdItemsDeleteWithHttpInfoAsync(int programScheduleId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("programScheduleId", ErsatzTV.Api.Sdk.Client.ClientUtils.ParameterToString(programScheduleId)); // path parameter - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.DeleteAsync>("/api/schedules/{programScheduleId}/items", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiSchedulesProgramScheduleIdItemsDelete", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// List<ProgramScheduleItemViewModel> - public List ApiSchedulesProgramScheduleIdItemsGet(int programScheduleId) - { - ErsatzTV.Api.Sdk.Client.ApiResponse> localVarResponse = ApiSchedulesProgramScheduleIdItemsGetWithHttpInfo(programScheduleId); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of List<ProgramScheduleItemViewModel> - public ErsatzTV.Api.Sdk.Client.ApiResponse> ApiSchedulesProgramScheduleIdItemsGetWithHttpInfo(int programScheduleId) - { - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("programScheduleId", ErsatzTV.Api.Sdk.Client.ClientUtils.ParameterToString(programScheduleId)); // path parameter - - - // make the HTTP request - var localVarResponse = this.Client.Get>("/api/schedules/{programScheduleId}/items", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiSchedulesProgramScheduleIdItemsGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of List<ProgramScheduleItemViewModel> - public async System.Threading.Tasks.Task> ApiSchedulesProgramScheduleIdItemsGetAsync(int programScheduleId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse> localVarResponse = await ApiSchedulesProgramScheduleIdItemsGetWithHttpInfoAsync(programScheduleId, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<ProgramScheduleItemViewModel>) - public async System.Threading.Tasks.Task>> ApiSchedulesProgramScheduleIdItemsGetWithHttpInfoAsync(int programScheduleId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("programScheduleId", ErsatzTV.Api.Sdk.Client.ClientUtils.ParameterToString(programScheduleId)); // path parameter - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.GetAsync>("/api/schedules/{programScheduleId}/items", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiSchedulesProgramScheduleIdItemsGet", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// - /// List<ProgramScheduleItemViewModel> - public List ApiSchedulesProgramScheduleIdItemsPut(int programScheduleId, List replaceProgramScheduleItem) - { - ErsatzTV.Api.Sdk.Client.ApiResponse> localVarResponse = ApiSchedulesProgramScheduleIdItemsPutWithHttpInfo(programScheduleId, replaceProgramScheduleItem); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// - /// ApiResponse of List<ProgramScheduleItemViewModel> - public ErsatzTV.Api.Sdk.Client.ApiResponse> ApiSchedulesProgramScheduleIdItemsPutWithHttpInfo(int programScheduleId, List replaceProgramScheduleItem) - { - // verify the required parameter 'replaceProgramScheduleItem' is set - if (replaceProgramScheduleItem == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'replaceProgramScheduleItem' when calling ProgramScheduleApi->ApiSchedulesProgramScheduleIdItemsPut"); - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("programScheduleId", ErsatzTV.Api.Sdk.Client.ClientUtils.ParameterToString(programScheduleId)); // path parameter - localVarRequestOptions.Data = replaceProgramScheduleItem; - - - // make the HTTP request - var localVarResponse = this.Client.Put>("/api/schedules/{programScheduleId}/items", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiSchedulesProgramScheduleIdItemsPut", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// - /// Cancellation Token to cancel the request. - /// Task of List<ProgramScheduleItemViewModel> - public async System.Threading.Tasks.Task> ApiSchedulesProgramScheduleIdItemsPutAsync(int programScheduleId, List replaceProgramScheduleItem, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - ErsatzTV.Api.Sdk.Client.ApiResponse> localVarResponse = await ApiSchedulesProgramScheduleIdItemsPutWithHttpInfoAsync(programScheduleId, replaceProgramScheduleItem, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// - /// - /// Thrown when fails to make API call - /// - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<ProgramScheduleItemViewModel>) - public async System.Threading.Tasks.Task>> ApiSchedulesProgramScheduleIdItemsPutWithHttpInfoAsync(int programScheduleId, List replaceProgramScheduleItem, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - // verify the required parameter 'replaceProgramScheduleItem' is set - if (replaceProgramScheduleItem == null) - throw new ErsatzTV.Api.Sdk.Client.ApiException(400, "Missing required parameter 'replaceProgramScheduleItem' when calling ProgramScheduleApi->ApiSchedulesProgramScheduleIdItemsPut"); - - - ErsatzTV.Api.Sdk.Client.RequestOptions localVarRequestOptions = new ErsatzTV.Api.Sdk.Client.RequestOptions(); - - String[] _contentTypes = new String[] { - "application/json-patch+json", - "application/json", - "text/json", - "application/_*+json" - }; - - // to determine the Accept header - String[] _accepts = new String[] { - "application/json" - }; - - - var localVarContentType = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = ErsatzTV.Api.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.PathParameters.Add("programScheduleId", ErsatzTV.Api.Sdk.Client.ClientUtils.ParameterToString(programScheduleId)); // path parameter - localVarRequestOptions.Data = replaceProgramScheduleItem; - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.PutAsync>("/api/schedules/{programScheduleId}/items", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ApiSchedulesProgramScheduleIdItemsPut", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - } -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/ApiClient.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/ApiClient.cs deleted file mode 100644 index 27755c813..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/ApiClient.cs +++ /dev/null @@ -1,835 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Net; -using System.Reflection; -using System.Runtime.Serialization; -using System.Runtime.Serialization.Formatters; -using System.Text; -using System.Threading; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using System.Web; -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; -using RestSharp; -using RestSharp.Deserializers; -using ErrorEventArgs = Newtonsoft.Json.Serialization.ErrorEventArgs; -using RestSharpMethod = RestSharp.Method; -using Polly; - -namespace ErsatzTV.Api.Sdk.Client -{ - /// - /// Allows RestSharp to Serialize/Deserialize JSON using our custom logic, but only when ContentType is JSON. - /// - internal class CustomJsonCodec : RestSharp.Serializers.ISerializer, RestSharp.Deserializers.IDeserializer - { - private readonly IReadableConfiguration _configuration; - private static readonly string _contentType = "application/json"; - private readonly JsonSerializerSettings _serializerSettings = new JsonSerializerSettings - { - // OpenAPI generated types generally hide default constructors. - ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor, - ContractResolver = new DefaultContractResolver - { - NamingStrategy = new CamelCaseNamingStrategy - { - OverrideSpecifiedNames = false - } - } - }; - - public CustomJsonCodec(IReadableConfiguration configuration) - { - _configuration = configuration; - } - - public CustomJsonCodec(JsonSerializerSettings serializerSettings, IReadableConfiguration configuration) - { - _serializerSettings = serializerSettings; - _configuration = configuration; - } - - /// - /// Serialize the object into a JSON string. - /// - /// Object to be serialized. - /// A JSON string. - public string Serialize(object obj) - { - if (obj != null && obj is ErsatzTV.Api.Sdk.Model.AbstractOpenAPISchema) - { - // the object to be serialized is an oneOf/anyOf schema - return ((ErsatzTV.Api.Sdk.Model.AbstractOpenAPISchema)obj).ToJson(); - } - else - { - return JsonConvert.SerializeObject(obj, _serializerSettings); - } - } - - public T Deserialize(IRestResponse response) - { - var result = (T)Deserialize(response, typeof(T)); - return result; - } - - /// - /// Deserialize the JSON string into a proper object. - /// - /// The HTTP response. - /// Object type. - /// Object representation of the JSON string. - internal object Deserialize(IRestResponse response, Type type) - { - IList headers = response.Headers; - if (type == typeof(byte[])) // return byte array - { - return response.RawBytes; - } - - // TODO: ? if (type.IsAssignableFrom(typeof(Stream))) - if (type == typeof(Stream)) - { - if (headers != null) - { - var filePath = String.IsNullOrEmpty(_configuration.TempFolderPath) - ? Path.GetTempPath() - : _configuration.TempFolderPath; - var regex = new Regex(@"Content-Disposition=.*filename=['""]?([^'""\s]+)['""]?$"); - foreach (var header in headers) - { - var match = regex.Match(header.ToString()); - if (match.Success) - { - string fileName = filePath + ClientUtils.SanitizeFilename(match.Groups[1].Value.Replace("\"", "").Replace("'", "")); - File.WriteAllBytes(fileName, response.RawBytes); - return new FileStream(fileName, FileMode.Open); - } - } - } - var stream = new MemoryStream(response.RawBytes); - return stream; - } - - if (type.Name.StartsWith("System.Nullable`1[[System.DateTime")) // return a datetime object - { - return DateTime.Parse(response.Content, null, System.Globalization.DateTimeStyles.RoundtripKind); - } - - if (type == typeof(String) || type.Name.StartsWith("System.Nullable")) // return primitive type - { - return Convert.ChangeType(response.Content, type); - } - - // at this point, it must be a model (json) - try - { - return JsonConvert.DeserializeObject(response.Content, type, _serializerSettings); - } - catch (Exception e) - { - throw new ApiException(500, e.Message); - } - } - - public string RootElement { get; set; } - public string Namespace { get; set; } - public string DateFormat { get; set; } - - public string ContentType - { - get { return _contentType; } - set { throw new InvalidOperationException("Not allowed to set content type."); } - } - } - /// - /// Provides a default implementation of an Api client (both synchronous and asynchronous implementatios), - /// encapsulating general REST accessor use cases. - /// - public partial class ApiClient : ISynchronousClient, IAsynchronousClient - { - private readonly String _baseUrl; - - /// - /// Specifies the settings on a object. - /// These settings can be adjusted to accomodate custom serialization rules. - /// - public JsonSerializerSettings SerializerSettings { get; set; } = new JsonSerializerSettings - { - // OpenAPI generated types generally hide default constructors. - ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor, - ContractResolver = new DefaultContractResolver - { - NamingStrategy = new CamelCaseNamingStrategy - { - OverrideSpecifiedNames = false - } - } - }; - - /// - /// Allows for extending request processing for generated code. - /// - /// The RestSharp request object - partial void InterceptRequest(IRestRequest request); - - /// - /// Allows for extending response processing for generated code. - /// - /// The RestSharp request object - /// The RestSharp response object - partial void InterceptResponse(IRestRequest request, IRestResponse response); - - /// - /// Initializes a new instance of the , defaulting to the global configurations' base url. - /// - public ApiClient() - { - _baseUrl = ErsatzTV.Api.Sdk.Client.GlobalConfiguration.Instance.BasePath; - } - - /// - /// Initializes a new instance of the - /// - /// The target service's base path in URL format. - /// - public ApiClient(String basePath) - { - if (string.IsNullOrEmpty(basePath)) - throw new ArgumentException("basePath cannot be empty"); - - _baseUrl = basePath; - } - - /// - /// Constructs the RestSharp version of an http method - /// - /// Swagger Client Custom HttpMethod - /// RestSharp's HttpMethod instance. - /// - private RestSharpMethod Method(HttpMethod method) - { - RestSharpMethod other; - switch (method) - { - case HttpMethod.Get: - other = RestSharpMethod.GET; - break; - case HttpMethod.Post: - other = RestSharpMethod.POST; - break; - case HttpMethod.Put: - other = RestSharpMethod.PUT; - break; - case HttpMethod.Delete: - other = RestSharpMethod.DELETE; - break; - case HttpMethod.Head: - other = RestSharpMethod.HEAD; - break; - case HttpMethod.Options: - other = RestSharpMethod.OPTIONS; - break; - case HttpMethod.Patch: - other = RestSharpMethod.PATCH; - break; - default: - throw new ArgumentOutOfRangeException("method", method, null); - } - - return other; - } - - /// - /// Provides all logic for constructing a new RestSharp . - /// At this point, all information for querying the service is known. Here, it is simply - /// mapped into the RestSharp request. - /// - /// The http verb. - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// [private] A new RestRequest instance. - /// - private RestRequest NewRequest( - HttpMethod method, - String path, - RequestOptions options, - IReadableConfiguration configuration) - { - if (path == null) throw new ArgumentNullException("path"); - if (options == null) throw new ArgumentNullException("options"); - if (configuration == null) throw new ArgumentNullException("configuration"); - - RestRequest request = new RestRequest(Method(method)) - { - Resource = path, - JsonSerializer = new CustomJsonCodec(SerializerSettings, configuration) - }; - - if (options.PathParameters != null) - { - foreach (var pathParam in options.PathParameters) - { - request.AddParameter(pathParam.Key, pathParam.Value, ParameterType.UrlSegment); - } - } - - if (options.QueryParameters != null) - { - foreach (var queryParam in options.QueryParameters) - { - foreach (var value in queryParam.Value) - { - request.AddQueryParameter(queryParam.Key, value); - } - } - } - - if (configuration.DefaultHeaders != null) - { - foreach (var headerParam in configuration.DefaultHeaders) - { - request.AddHeader(headerParam.Key, headerParam.Value); - } - } - - if (options.HeaderParameters != null) - { - foreach (var headerParam in options.HeaderParameters) - { - foreach (var value in headerParam.Value) - { - request.AddHeader(headerParam.Key, value); - } - } - } - - if (options.FormParameters != null) - { - foreach (var formParam in options.FormParameters) - { - request.AddParameter(formParam.Key, formParam.Value); - } - } - - if (options.Data != null) - { - if (options.HeaderParameters != null) - { - var contentTypes = options.HeaderParameters["Content-Type"]; - if (contentTypes == null || contentTypes.Any(header => header.Contains("application/json"))) - { - request.RequestFormat = DataFormat.Json; - } - else - { - // TODO: Generated client user should add additional handlers. RestSharp only supports XML and JSON, with XML as default. - } - } - else - { - // Here, we'll assume JSON APIs are more common. XML can be forced by adding produces/consumes to openapi spec explicitly. - request.RequestFormat = DataFormat.Json; - } - - request.AddJsonBody(options.Data); - } - - if (options.FileParameters != null) - { - foreach (var fileParam in options.FileParameters) - { - var bytes = ClientUtils.ReadAsBytes(fileParam.Value); - var fileStream = fileParam.Value as FileStream; - if (fileStream != null) - request.Files.Add(FileParameter.Create(fileParam.Key, bytes, System.IO.Path.GetFileName(fileStream.Name))); - else - request.Files.Add(FileParameter.Create(fileParam.Key, bytes, "no_file_name_provided")); - } - } - - if (options.Cookies != null && options.Cookies.Count > 0) - { - foreach (var cookie in options.Cookies) - { - request.AddCookie(cookie.Name, cookie.Value); - } - } - - return request; - } - - private ApiResponse ToApiResponse(IRestResponse response) - { - T result = response.Data; - string rawContent = response.Content; - - var transformed = new ApiResponse(response.StatusCode, new Multimap(), result, rawContent) - { - ErrorText = response.ErrorMessage, - Cookies = new List() - }; - - if (response.Headers != null) - { - foreach (var responseHeader in response.Headers) - { - transformed.Headers.Add(responseHeader.Name, ClientUtils.ParameterToString(responseHeader.Value)); - } - } - - if (response.Cookies != null) - { - foreach (var responseCookies in response.Cookies) - { - transformed.Cookies.Add( - new Cookie( - responseCookies.Name, - responseCookies.Value, - responseCookies.Path, - responseCookies.Domain) - ); - } - } - - return transformed; - } - - private ApiResponse Exec(RestRequest req, IReadableConfiguration configuration) - { - RestClient client = new RestClient(_baseUrl); - - client.ClearHandlers(); - var existingDeserializer = req.JsonSerializer as IDeserializer; - if (existingDeserializer != null) - { - client.AddHandler("application/json", () => existingDeserializer); - client.AddHandler("text/json", () => existingDeserializer); - client.AddHandler("text/x-json", () => existingDeserializer); - client.AddHandler("text/javascript", () => existingDeserializer); - client.AddHandler("*+json", () => existingDeserializer); - } - else - { - var customDeserializer = new CustomJsonCodec(SerializerSettings, configuration); - client.AddHandler("application/json", () => customDeserializer); - client.AddHandler("text/json", () => customDeserializer); - client.AddHandler("text/x-json", () => customDeserializer); - client.AddHandler("text/javascript", () => customDeserializer); - client.AddHandler("*+json", () => customDeserializer); - } - - var xmlDeserializer = new XmlDeserializer(); - client.AddHandler("application/xml", () => xmlDeserializer); - client.AddHandler("text/xml", () => xmlDeserializer); - client.AddHandler("*+xml", () => xmlDeserializer); - client.AddHandler("*", () => xmlDeserializer); - - client.Timeout = configuration.Timeout; - - if (configuration.Proxy != null) - { - client.Proxy = configuration.Proxy; - } - - if (configuration.UserAgent != null) - { - client.UserAgent = configuration.UserAgent; - } - - if (configuration.ClientCertificates != null) - { - client.ClientCertificates = configuration.ClientCertificates; - } - - InterceptRequest(req); - - IRestResponse response; - if (RetryConfiguration.RetryPolicy != null) - { - var policy = RetryConfiguration.RetryPolicy; - var policyResult = policy.ExecuteAndCapture(() => client.Execute(req)); - response = (policyResult.Outcome == OutcomeType.Successful) ? client.Deserialize(policyResult.Result) : new RestResponse - { - Request = req, - ErrorException = policyResult.FinalException - }; - } - else - { - response = client.Execute(req); - } - - InterceptResponse(req, response); - - var result = ToApiResponse(response); - if (response.ErrorMessage != null) - { - result.ErrorText = response.ErrorMessage; - } - - if (response.Cookies != null && response.Cookies.Count > 0) - { - if (result.Cookies == null) result.Cookies = new List(); - foreach (var restResponseCookie in response.Cookies) - { - var cookie = new Cookie( - restResponseCookie.Name, - restResponseCookie.Value, - restResponseCookie.Path, - restResponseCookie.Domain - ) - { - Comment = restResponseCookie.Comment, - CommentUri = restResponseCookie.CommentUri, - Discard = restResponseCookie.Discard, - Expired = restResponseCookie.Expired, - Expires = restResponseCookie.Expires, - HttpOnly = restResponseCookie.HttpOnly, - Port = restResponseCookie.Port, - Secure = restResponseCookie.Secure, - Version = restResponseCookie.Version - }; - - result.Cookies.Add(cookie); - } - } - return result; - } - - private async Task> ExecAsync(RestRequest req, IReadableConfiguration configuration, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - RestClient client = new RestClient(_baseUrl); - - client.ClearHandlers(); - var existingDeserializer = req.JsonSerializer as IDeserializer; - if (existingDeserializer != null) - { - client.AddHandler("application/json", () => existingDeserializer); - client.AddHandler("text/json", () => existingDeserializer); - client.AddHandler("text/x-json", () => existingDeserializer); - client.AddHandler("text/javascript", () => existingDeserializer); - client.AddHandler("*+json", () => existingDeserializer); - } - else - { - var customDeserializer = new CustomJsonCodec(SerializerSettings, configuration); - client.AddHandler("application/json", () => customDeserializer); - client.AddHandler("text/json", () => customDeserializer); - client.AddHandler("text/x-json", () => customDeserializer); - client.AddHandler("text/javascript", () => customDeserializer); - client.AddHandler("*+json", () => customDeserializer); - } - - var xmlDeserializer = new XmlDeserializer(); - client.AddHandler("application/xml", () => xmlDeserializer); - client.AddHandler("text/xml", () => xmlDeserializer); - client.AddHandler("*+xml", () => xmlDeserializer); - client.AddHandler("*", () => xmlDeserializer); - - client.Timeout = configuration.Timeout; - - if (configuration.Proxy != null) - { - client.Proxy = configuration.Proxy; - } - - if (configuration.UserAgent != null) - { - client.UserAgent = configuration.UserAgent; - } - - if (configuration.ClientCertificates != null) - { - client.ClientCertificates = configuration.ClientCertificates; - } - - InterceptRequest(req); - - IRestResponse response; - if (RetryConfiguration.AsyncRetryPolicy != null) - { - var policy = RetryConfiguration.AsyncRetryPolicy; - var policyResult = await policy.ExecuteAndCaptureAsync(() => client.ExecuteAsync(req, cancellationToken)).ConfigureAwait(false); - response = (policyResult.Outcome == OutcomeType.Successful) ? client.Deserialize(policyResult.Result) : new RestResponse - { - Request = req, - ErrorException = policyResult.FinalException - }; - } - else - { - response = await client.ExecuteAsync(req, cancellationToken).ConfigureAwait(false); - } - - // if the response type is oneOf/anyOf, call FromJSON to deserialize the data - if (typeof(ErsatzTV.Api.Sdk.Model.AbstractOpenAPISchema).IsAssignableFrom(typeof(T))) - { - T instance = (T)Activator.CreateInstance(typeof(T)); - MethodInfo method = typeof(T).GetMethod("FromJson"); - method.Invoke(instance, new object[] { response.Content }); - response.Data = instance; - } - - InterceptResponse(req, response); - - var result = ToApiResponse(response); - if (response.ErrorMessage != null) - { - result.ErrorText = response.ErrorMessage; - } - - if (response.Cookies != null && response.Cookies.Count > 0) - { - if (result.Cookies == null) result.Cookies = new List(); - foreach (var restResponseCookie in response.Cookies) - { - var cookie = new Cookie( - restResponseCookie.Name, - restResponseCookie.Value, - restResponseCookie.Path, - restResponseCookie.Domain - ) - { - Comment = restResponseCookie.Comment, - CommentUri = restResponseCookie.CommentUri, - Discard = restResponseCookie.Discard, - Expired = restResponseCookie.Expired, - Expires = restResponseCookie.Expires, - HttpOnly = restResponseCookie.HttpOnly, - Port = restResponseCookie.Port, - Secure = restResponseCookie.Secure, - Version = restResponseCookie.Version - }; - - result.Cookies.Add(cookie); - } - } - return result; - } - - #region IAsynchronousClient - /// - /// Make a HTTP GET request (async). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// Token that enables callers to cancel the request. - /// A Task containing ApiResponse - public Task> GetAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - var config = configuration ?? GlobalConfiguration.Instance; - return ExecAsync(NewRequest(HttpMethod.Get, path, options, config), config, cancellationToken); - } - - /// - /// Make a HTTP POST request (async). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// Token that enables callers to cancel the request. - /// A Task containing ApiResponse - public Task> PostAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - var config = configuration ?? GlobalConfiguration.Instance; - return ExecAsync(NewRequest(HttpMethod.Post, path, options, config), config, cancellationToken); - } - - /// - /// Make a HTTP PUT request (async). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// Token that enables callers to cancel the request. - /// A Task containing ApiResponse - public Task> PutAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - var config = configuration ?? GlobalConfiguration.Instance; - return ExecAsync(NewRequest(HttpMethod.Put, path, options, config), config, cancellationToken); - } - - /// - /// Make a HTTP DELETE request (async). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// Token that enables callers to cancel the request. - /// A Task containing ApiResponse - public Task> DeleteAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - var config = configuration ?? GlobalConfiguration.Instance; - return ExecAsync(NewRequest(HttpMethod.Delete, path, options, config), config, cancellationToken); - } - - /// - /// Make a HTTP HEAD request (async). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// Token that enables callers to cancel the request. - /// A Task containing ApiResponse - public Task> HeadAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - var config = configuration ?? GlobalConfiguration.Instance; - return ExecAsync(NewRequest(HttpMethod.Head, path, options, config), config, cancellationToken); - } - - /// - /// Make a HTTP OPTION request (async). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// Token that enables callers to cancel the request. - /// A Task containing ApiResponse - public Task> OptionsAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - var config = configuration ?? GlobalConfiguration.Instance; - return ExecAsync(NewRequest(HttpMethod.Options, path, options, config), config, cancellationToken); - } - - /// - /// Make a HTTP PATCH request (async). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// Token that enables callers to cancel the request. - /// A Task containing ApiResponse - public Task> PatchAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - var config = configuration ?? GlobalConfiguration.Instance; - return ExecAsync(NewRequest(HttpMethod.Patch, path, options, config), config, cancellationToken); - } - #endregion IAsynchronousClient - - #region ISynchronousClient - /// - /// Make a HTTP GET request (synchronous). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// A Task containing ApiResponse - public ApiResponse Get(string path, RequestOptions options, IReadableConfiguration configuration = null) - { - var config = configuration ?? GlobalConfiguration.Instance; - return Exec(NewRequest(HttpMethod.Get, path, options, config), config); - } - - /// - /// Make a HTTP POST request (synchronous). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// A Task containing ApiResponse - public ApiResponse Post(string path, RequestOptions options, IReadableConfiguration configuration = null) - { - var config = configuration ?? GlobalConfiguration.Instance; - return Exec(NewRequest(HttpMethod.Post, path, options, config), config); - } - - /// - /// Make a HTTP PUT request (synchronous). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// A Task containing ApiResponse - public ApiResponse Put(string path, RequestOptions options, IReadableConfiguration configuration = null) - { - var config = configuration ?? GlobalConfiguration.Instance; - return Exec(NewRequest(HttpMethod.Put, path, options, config), config); - } - - /// - /// Make a HTTP DELETE request (synchronous). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// A Task containing ApiResponse - public ApiResponse Delete(string path, RequestOptions options, IReadableConfiguration configuration = null) - { - var config = configuration ?? GlobalConfiguration.Instance; - return Exec(NewRequest(HttpMethod.Delete, path, options, config), config); - } - - /// - /// Make a HTTP HEAD request (synchronous). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// A Task containing ApiResponse - public ApiResponse Head(string path, RequestOptions options, IReadableConfiguration configuration = null) - { - var config = configuration ?? GlobalConfiguration.Instance; - return Exec(NewRequest(HttpMethod.Head, path, options, config), config); - } - - /// - /// Make a HTTP OPTION request (synchronous). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// A Task containing ApiResponse - public ApiResponse Options(string path, RequestOptions options, IReadableConfiguration configuration = null) - { - var config = configuration ?? GlobalConfiguration.Instance; - return Exec(NewRequest(HttpMethod.Options, path, options, config), config); - } - - /// - /// Make a HTTP PATCH request (synchronous). - /// - /// The target path (or resource). - /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. - /// A Task containing ApiResponse - public ApiResponse Patch(string path, RequestOptions options, IReadableConfiguration configuration = null) - { - var config = configuration ?? GlobalConfiguration.Instance; - return Exec(NewRequest(HttpMethod.Patch, path, options, config), config); - } - #endregion ISynchronousClient - } -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/ApiException.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/ApiException.cs deleted file mode 100644 index d5cc8059a..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/ApiException.cs +++ /dev/null @@ -1,68 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; - -namespace ErsatzTV.Api.Sdk.Client -{ - /// - /// API Exception - /// - public class ApiException : Exception - { - /// - /// Gets or sets the error code (HTTP status code) - /// - /// The error code (HTTP status code). - public int ErrorCode { get; set; } - - /// - /// Gets or sets the error content (body json object) - /// - /// The error content (Http response body). - public object ErrorContent { get; private set; } - - /// - /// Gets or sets the HTTP headers - /// - /// HTTP headers - public Multimap Headers { get; private set; } - - /// - /// Initializes a new instance of the class. - /// - public ApiException() { } - - /// - /// Initializes a new instance of the class. - /// - /// HTTP status code. - /// Error message. - public ApiException(int errorCode, string message) : base(message) - { - this.ErrorCode = errorCode; - } - - /// - /// Initializes a new instance of the class. - /// - /// HTTP status code. - /// Error message. - /// Error content. - /// HTTP Headers. - public ApiException(int errorCode, string message, object errorContent = null, Multimap headers = null) : base(message) - { - this.ErrorCode = errorCode; - this.ErrorContent = errorContent; - this.Headers = headers; - } - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/ApiResponse.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/ApiResponse.cs deleted file mode 100644 index 5f91f6f92..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/ApiResponse.cs +++ /dev/null @@ -1,166 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections.Generic; -using System.Net; - -namespace ErsatzTV.Api.Sdk.Client -{ - /// - /// Provides a non-generic contract for the ApiResponse wrapper. - /// - public interface IApiResponse - { - /// - /// The data type of - /// - Type ResponseType { get; } - - /// - /// The content of this response - /// - Object Content { get; } - - /// - /// Gets or sets the status code (HTTP status code) - /// - /// The status code. - HttpStatusCode StatusCode { get; } - - /// - /// Gets or sets the HTTP headers - /// - /// HTTP headers - Multimap Headers { get; } - - /// - /// Gets or sets any error text defined by the calling client. - /// - String ErrorText { get; set; } - - /// - /// Gets or sets any cookies passed along on the response. - /// - List Cookies { get; set; } - - /// - /// The raw content of this response - /// - string RawContent { get; } - } - - /// - /// API Response - /// - public class ApiResponse : IApiResponse - { - #region Properties - - /// - /// Gets or sets the status code (HTTP status code) - /// - /// The status code. - public HttpStatusCode StatusCode { get; } - - /// - /// Gets or sets the HTTP headers - /// - /// HTTP headers - public Multimap Headers { get; } - - /// - /// Gets or sets the data (parsed HTTP body) - /// - /// The data. - public T Data { get; } - - /// - /// Gets or sets any error text defined by the calling client. - /// - public String ErrorText { get; set; } - - /// - /// Gets or sets any cookies passed along on the response. - /// - public List Cookies { get; set; } - - /// - /// The content of this response - /// - public Type ResponseType - { - get { return typeof(T); } - } - - /// - /// The data type of - /// - public object Content - { - get { return Data; } - } - - /// - /// The raw content - /// - public string RawContent { get; } - - #endregion Properties - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// HTTP status code. - /// HTTP headers. - /// Data (parsed HTTP body) - /// Raw content. - public ApiResponse(HttpStatusCode statusCode, Multimap headers, T data, string rawContent) - { - StatusCode = statusCode; - Headers = headers; - Data = data; - RawContent = rawContent; - } - - /// - /// Initializes a new instance of the class. - /// - /// HTTP status code. - /// HTTP headers. - /// Data (parsed HTTP body) - public ApiResponse(HttpStatusCode statusCode, Multimap headers, T data) : this(statusCode, headers, data, null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// HTTP status code. - /// Data (parsed HTTP body) - /// Raw content. - public ApiResponse(HttpStatusCode statusCode, T data, string rawContent) : this(statusCode, null, data, rawContent) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// HTTP status code. - /// Data (parsed HTTP body) - public ApiResponse(HttpStatusCode statusCode, T data) : this(statusCode, data, null) - { - } - - #endregion Constructors - } -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/ClientUtils.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/ClientUtils.cs deleted file mode 100644 index 0b88820b9..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/ClientUtils.cs +++ /dev/null @@ -1,214 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; - -namespace ErsatzTV.Api.Sdk.Client -{ - /// - /// Utility functions providing some benefit to API client consumers. - /// - public static class ClientUtils - { - /// - /// Sanitize filename by removing the path - /// - /// Filename - /// Filename - public static string SanitizeFilename(string filename) - { - Match match = Regex.Match(filename, @".*[/\\](.*)$"); - return match.Success ? match.Groups[1].Value : filename; - } - - /// - /// Convert params to key/value pairs. - /// Use collectionFormat to properly format lists and collections. - /// - /// The swagger-supported collection format, one of: csv, tsv, ssv, pipes, multi - /// Key name. - /// Value object. - /// A multimap of keys with 1..n associated values. - public static Multimap ParameterToMultiMap(string collectionFormat, string name, object value) - { - var parameters = new Multimap(); - - if (value is ICollection collection && collectionFormat == "multi") - { - foreach (var item in collection) - { - parameters.Add(name, ParameterToString(item)); - } - } - else - { - parameters.Add(name, ParameterToString(value)); - } - - return parameters; - } - - /// - /// If parameter is DateTime, output in a formatted string (default ISO 8601), customizable with Configuration.DateTime. - /// If parameter is a list, join the list with ",". - /// Otherwise just return the string. - /// - /// The parameter (header, path, query, form). - /// An optional configuration instance, providing formatting options used in processing. - /// Formatted string. - public static string ParameterToString(object obj, IReadableConfiguration configuration = null) - { - if (obj is DateTime dateTime) - // Return a formatted date string - Can be customized with Configuration.DateTimeFormat - // Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o") - // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 - // For example: 2009-06-15T13:45:30.0000000 - return dateTime.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat); - if (obj is DateTimeOffset dateTimeOffset) - // Return a formatted date string - Can be customized with Configuration.DateTimeFormat - // Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o") - // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 - // For example: 2009-06-15T13:45:30.0000000 - return dateTimeOffset.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat); - if (obj is bool boolean) - return boolean ? "true" : "false"; - if (obj is ICollection collection) - return string.Join(",", collection.Cast()); - - return Convert.ToString(obj, CultureInfo.InvariantCulture); - } - - /// - /// URL encode a string - /// Credit/Ref: https://github.com/restsharp/RestSharp/blob/master/RestSharp/Extensions/StringExtensions.cs#L50 - /// - /// String to be URL encoded - /// Byte array - public static string UrlEncode(string input) - { - const int maxLength = 32766; - - if (input == null) - { - throw new ArgumentNullException("input"); - } - - if (input.Length <= maxLength) - { - return Uri.EscapeDataString(input); - } - - StringBuilder sb = new StringBuilder(input.Length * 2); - int index = 0; - - while (index < input.Length) - { - int length = Math.Min(input.Length - index, maxLength); - string subString = input.Substring(index, length); - - sb.Append(Uri.EscapeDataString(subString)); - index += subString.Length; - } - - return sb.ToString(); - } - - /// - /// Encode string in base64 format. - /// - /// String to be encoded. - /// Encoded string. - public static string Base64Encode(string text) - { - return Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(text)); - } - - /// - /// Convert stream to byte array - /// - /// Input stream to be converted - /// Byte array - public static byte[] ReadAsBytes(Stream inputStream) - { - using (var ms = new MemoryStream()) - { - inputStream.CopyTo(ms); - return ms.ToArray(); - } - } - - /// - /// Select the Content-Type header's value from the given content-type array: - /// if JSON type exists in the given array, use it; - /// otherwise use the first one defined in 'consumes' - /// - /// The Content-Type array to select from. - /// The Content-Type header to use. - public static String SelectHeaderContentType(String[] contentTypes) - { - if (contentTypes.Length == 0) - return null; - - foreach (var contentType in contentTypes) - { - if (IsJsonMime(contentType)) - return contentType; - } - - return contentTypes[0]; // use the first content type specified in 'consumes' - } - - /// - /// Select the Accept header's value from the given accepts array: - /// if JSON exists in the given array, use it; - /// otherwise use all of them (joining into a string) - /// - /// The accepts array to select from. - /// The Accept header to use. - public static String SelectHeaderAccept(String[] accepts) - { - if (accepts.Length == 0) - return null; - - if (accepts.Contains("application/json", StringComparer.OrdinalIgnoreCase)) - return "application/json"; - - return String.Join(",", accepts); - } - - /// - /// Provides a case-insensitive check that a provided content type is a known JSON-like content type. - /// - public static readonly Regex JsonRegex = new Regex("(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"); - - /// - /// Check if the given MIME is a JSON MIME. - /// JSON MIME examples: - /// application/json - /// application/json; charset=UTF8 - /// APPLICATION/JSON - /// application/vnd.company+json - /// - /// MIME - /// Returns True if MIME type is json. - public static bool IsJsonMime(String mime) - { - if (String.IsNullOrWhiteSpace(mime)) return false; - - return JsonRegex.IsMatch(mime) || mime.Equals("application/json-patch+json"); - } - } -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/Configuration.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/Configuration.cs deleted file mode 100644 index 51107a6f9..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/Configuration.cs +++ /dev/null @@ -1,520 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net; -using System.Reflection; -using System.Security.Cryptography.X509Certificates; -using System.Text; - -namespace ErsatzTV.Api.Sdk.Client -{ - /// - /// Represents a set of configuration settings - /// - public class Configuration : IReadableConfiguration - { - #region Constants - - /// - /// Version of the package. - /// - /// Version of the package. - public const string Version = "1.0.0"; - - /// - /// Identifier for ISO 8601 DateTime Format - /// - /// See https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 for more information. - // ReSharper disable once InconsistentNaming - public const string ISO8601_DATETIME_FORMAT = "o"; - - #endregion Constants - - #region Static Members - - /// - /// Default creation of exceptions for a given method name and response object - /// - public static readonly ExceptionFactory DefaultExceptionFactory = (methodName, response) => - { - var status = (int)response.StatusCode; - if (status >= 400) - { - return new ApiException(status, - string.Format("Error calling {0}: {1}", methodName, response.RawContent), - response.RawContent, response.Headers); - } - if (status == 0) - { - return new ApiException(status, - string.Format("Error calling {0}: {1}", methodName, response.ErrorText), response.ErrorText); - } - return null; - }; - - #endregion Static Members - - #region Private Members - - /// - /// Defines the base path of the target API server. - /// Example: http://localhost:3000/v1/ - /// - private String _basePath; - - /// - /// Gets or sets the API key based on the authentication name. - /// This is the key and value comprising the "secret" for acessing an API. - /// - /// The API key. - private IDictionary _apiKey; - - /// - /// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name. - /// - /// The prefix of the API key. - private IDictionary _apiKeyPrefix; - - private string _dateTimeFormat = ISO8601_DATETIME_FORMAT; - private string _tempFolderPath = Path.GetTempPath(); - - /// - /// Gets or sets the servers defined in the OpenAPI spec. - /// - /// The servers - private IList> _servers; - #endregion Private Members - - #region Constructors - - /// - /// Initializes a new instance of the class - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "VirtualMemberCallInConstructor")] - public Configuration() - { - Proxy = null; - UserAgent = "OpenAPI-Generator/1.0.0/csharp"; - BasePath = "http://localhost"; - DefaultHeaders = new ConcurrentDictionary(); - ApiKey = new ConcurrentDictionary(); - ApiKeyPrefix = new ConcurrentDictionary(); - Servers = new List>() - { - { - new Dictionary { - {"url", "/"}, - {"description", "No description provided"}, - } - } - }; - - // Setting Timeout has side effects (forces ApiClient creation). - Timeout = 100000; - } - - /// - /// Initializes a new instance of the class - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "VirtualMemberCallInConstructor")] - public Configuration( - IDictionary defaultHeaders, - IDictionary apiKey, - IDictionary apiKeyPrefix, - string basePath = "http://localhost") : this() - { - if (string.IsNullOrWhiteSpace(basePath)) - throw new ArgumentException("The provided basePath is invalid.", "basePath"); - if (defaultHeaders == null) - throw new ArgumentNullException("defaultHeaders"); - if (apiKey == null) - throw new ArgumentNullException("apiKey"); - if (apiKeyPrefix == null) - throw new ArgumentNullException("apiKeyPrefix"); - - BasePath = basePath; - - foreach (var keyValuePair in defaultHeaders) - { - DefaultHeaders.Add(keyValuePair); - } - - foreach (var keyValuePair in apiKey) - { - ApiKey.Add(keyValuePair); - } - - foreach (var keyValuePair in apiKeyPrefix) - { - ApiKeyPrefix.Add(keyValuePair); - } - } - - #endregion Constructors - - #region Properties - - /// - /// Gets or sets the base path for API access. - /// - public virtual string BasePath { - get { return _basePath; } - set { _basePath = value; } - } - - /// - /// Gets or sets the default header. - /// - [Obsolete("Use DefaultHeaders instead.")] - public virtual IDictionary DefaultHeader - { - get - { - return DefaultHeaders; - } - set - { - DefaultHeaders = value; - } - } - - /// - /// Gets or sets the default headers. - /// - public virtual IDictionary DefaultHeaders { get; set; } - - /// - /// Gets or sets the HTTP timeout (milliseconds) of ApiClient. Default to 100000 milliseconds. - /// - public virtual int Timeout { get; set; } - - /// - /// Gets or sets the proxy - /// - /// Proxy. - public virtual WebProxy Proxy { get; set; } - - /// - /// Gets or sets the HTTP user agent. - /// - /// Http user agent. - public virtual string UserAgent { get; set; } - - /// - /// Gets or sets the username (HTTP basic authentication). - /// - /// The username. - public virtual string Username { get; set; } - - /// - /// Gets or sets the password (HTTP basic authentication). - /// - /// The password. - public virtual string Password { get; set; } - - /// - /// Gets the API key with prefix. - /// - /// API key identifier (authentication scheme). - /// API key with prefix. - public string GetApiKeyWithPrefix(string apiKeyIdentifier) - { - string apiKeyValue; - ApiKey.TryGetValue(apiKeyIdentifier, out apiKeyValue); - string apiKeyPrefix; - if (ApiKeyPrefix.TryGetValue(apiKeyIdentifier, out apiKeyPrefix)) - { - return apiKeyPrefix + " " + apiKeyValue; - } - - return apiKeyValue; - } - - /// - /// Gets or sets certificate collection to be sent with requests. - /// - /// X509 Certificate collection. - public X509CertificateCollection ClientCertificates { get; set; } - - /// - /// Gets or sets the access token for OAuth2 authentication. - /// - /// This helper property simplifies code generation. - /// - /// The access token. - public virtual string AccessToken { get; set; } - - /// - /// Gets or sets the temporary folder path to store the files downloaded from the server. - /// - /// Folder path. - public virtual string TempFolderPath - { - get { return _tempFolderPath; } - - set - { - if (string.IsNullOrEmpty(value)) - { - _tempFolderPath = Path.GetTempPath(); - return; - } - - // create the directory if it does not exist - if (!Directory.Exists(value)) - { - Directory.CreateDirectory(value); - } - - // check if the path contains directory separator at the end - if (value[value.Length - 1] == Path.DirectorySeparatorChar) - { - _tempFolderPath = value; - } - else - { - _tempFolderPath = value + Path.DirectorySeparatorChar; - } - } - } - - /// - /// Gets or sets the date time format used when serializing in the ApiClient - /// By default, it's set to ISO 8601 - "o", for others see: - /// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx - /// and https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx - /// No validation is done to ensure that the string you're providing is valid - /// - /// The DateTimeFormat string - public virtual string DateTimeFormat - { - get { return _dateTimeFormat; } - set - { - if (string.IsNullOrEmpty(value)) - { - // Never allow a blank or null string, go back to the default - _dateTimeFormat = ISO8601_DATETIME_FORMAT; - return; - } - - // Caution, no validation when you choose date time format other than ISO 8601 - // Take a look at the above links - _dateTimeFormat = value; - } - } - - /// - /// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name. - /// - /// Whatever you set here will be prepended to the value defined in AddApiKey. - /// - /// An example invocation here might be: - /// - /// ApiKeyPrefix["Authorization"] = "Bearer"; - /// - /// … where ApiKey["Authorization"] would then be used to set the value of your bearer token. - /// - /// - /// OAuth2 workflows should set tokens via AccessToken. - /// - /// - /// The prefix of the API key. - public virtual IDictionary ApiKeyPrefix - { - get { return _apiKeyPrefix; } - set - { - if (value == null) - { - throw new InvalidOperationException("ApiKeyPrefix collection may not be null."); - } - _apiKeyPrefix = value; - } - } - - /// - /// Gets or sets the API key based on the authentication name. - /// - /// The API key. - public virtual IDictionary ApiKey - { - get { return _apiKey; } - set - { - if (value == null) - { - throw new InvalidOperationException("ApiKey collection may not be null."); - } - _apiKey = value; - } - } - - /// - /// Gets or sets the servers. - /// - /// The servers. - public virtual IList> Servers - { - get { return _servers; } - set - { - if (value == null) - { - throw new InvalidOperationException("Servers may not be null."); - } - _servers = value; - } - } - - /// - /// Returns URL based on server settings without providing values - /// for the variables - /// - /// Array index of the server settings. - /// The server URL. - public string GetServerUrl(int index) - { - return GetServerUrl(index, null); - } - - /// - /// Returns URL based on server settings. - /// - /// Array index of the server settings. - /// Dictionary of the variables and the corresponding values. - /// The server URL. - public string GetServerUrl(int index, Dictionary inputVariables) - { - if (index < 0 || index >= Servers.Count) - { - throw new InvalidOperationException($"Invalid index {index} when selecting the server. Must be less than {Servers.Count}."); - } - - if (inputVariables == null) - { - inputVariables = new Dictionary(); - } - - IReadOnlyDictionary server = Servers[index]; - string url = (string)server["url"]; - - // go through variable and assign a value - foreach (KeyValuePair variable in (IReadOnlyDictionary)server["variables"]) - { - - IReadOnlyDictionary serverVariables = (IReadOnlyDictionary)(variable.Value); - - if (inputVariables.ContainsKey(variable.Key)) - { - if (((List)serverVariables["enum_values"]).Contains(inputVariables[variable.Key])) - { - url = url.Replace("{" + variable.Key + "}", inputVariables[variable.Key]); - } - else - { - throw new InvalidOperationException($"The variable `{variable.Key}` in the server URL has invalid value #{inputVariables[variable.Key]}. Must be {(List)serverVariables["enum_values"]}"); - } - } - else - { - // use defualt value - url = url.Replace("{" + variable.Key + "}", (string)serverVariables["default_value"]); - } - } - - return url; - } - - #endregion Properties - - #region Methods - - /// - /// Returns a string with essential information for debugging. - /// - public static String ToDebugReport() - { - String report = "C# SDK (ErsatzTV.Api.Sdk) Debug Report:\n"; - report += " OS: " + System.Environment.OSVersion + "\n"; - report += " .NET Framework Version: " + System.Environment.Version + "\n"; - report += " Version of the API: v1\n"; - report += " SDK Package Version: 1.0.0\n"; - - return report; - } - - /// - /// Add Api Key Header. - /// - /// Api Key name. - /// Api Key value. - /// - public void AddApiKey(string key, string value) - { - ApiKey[key] = value; - } - - /// - /// Sets the API key prefix. - /// - /// Api Key name. - /// Api Key value. - public void AddApiKeyPrefix(string key, string value) - { - ApiKeyPrefix[key] = value; - } - - #endregion Methods - - #region Static Members - /// - /// Merge configurations. - /// - /// First configuration. - /// Second configuration. - /// Merged configuration. - public static IReadableConfiguration MergeConfigurations(IReadableConfiguration first, IReadableConfiguration second) - { - if (second == null) return first ?? GlobalConfiguration.Instance; - - Dictionary apiKey = first.ApiKey.ToDictionary(kvp => kvp.Key, kvp => kvp.Value); - Dictionary apiKeyPrefix = first.ApiKeyPrefix.ToDictionary(kvp => kvp.Key, kvp => kvp.Value); - Dictionary defaultHeaders = first.DefaultHeaders.ToDictionary(kvp => kvp.Key, kvp => kvp.Value); - - foreach (var kvp in second.ApiKey) apiKey[kvp.Key] = kvp.Value; - foreach (var kvp in second.ApiKeyPrefix) apiKeyPrefix[kvp.Key] = kvp.Value; - foreach (var kvp in second.DefaultHeaders) defaultHeaders[kvp.Key] = kvp.Value; - - var config = new Configuration - { - ApiKey = apiKey, - ApiKeyPrefix = apiKeyPrefix, - DefaultHeaders = defaultHeaders, - BasePath = second.BasePath ?? first.BasePath, - Timeout = second.Timeout, - Proxy = second.Proxy ?? first.Proxy, - UserAgent = second.UserAgent ?? first.UserAgent, - Username = second.Username ?? first.Username, - Password = second.Password ?? first.Password, - AccessToken = second.AccessToken ?? first.AccessToken, - TempFolderPath = second.TempFolderPath ?? first.TempFolderPath, - DateTimeFormat = second.DateTimeFormat ?? first.DateTimeFormat - }; - return config; - } - #endregion Static Members - } -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/ExceptionFactory.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/ExceptionFactory.cs deleted file mode 100644 index 907ea04a8..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/ExceptionFactory.cs +++ /dev/null @@ -1,22 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; - -namespace ErsatzTV.Api.Sdk.Client -{ - /// - /// A delegate to ExceptionFactory method - /// - /// Method name - /// Response - /// Exceptions - public delegate Exception ExceptionFactory(string methodName, IApiResponse response); -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/GlobalConfiguration.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/GlobalConfiguration.cs deleted file mode 100644 index 8d65006b0..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/GlobalConfiguration.cs +++ /dev/null @@ -1,67 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System.Collections.Generic; - -namespace ErsatzTV.Api.Sdk.Client -{ - /// - /// provides a compile-time extension point for globally configuring - /// API Clients. - /// - /// - /// A customized implementation via partial class may reside in another file and may - /// be excluded from automatic generation via a .openapi-generator-ignore file. - /// - public partial class GlobalConfiguration : Configuration - { - #region Private Members - - private static readonly object GlobalConfigSync = new { }; - private static IReadableConfiguration _globalConfiguration; - - #endregion Private Members - - #region Constructors - - /// - private GlobalConfiguration() - { - } - - /// - public GlobalConfiguration(IDictionary defaultHeader, IDictionary apiKey, IDictionary apiKeyPrefix, string basePath = "http://localhost:3000/api") : base(defaultHeader, apiKey, apiKeyPrefix, basePath) - { - } - - static GlobalConfiguration() - { - Instance = new GlobalConfiguration(); - } - - #endregion Constructors - - /// - /// Gets or sets the default Configuration. - /// - /// Configuration. - public static IReadableConfiguration Instance - { - get { return _globalConfiguration; } - set - { - lock (GlobalConfigSync) - { - _globalConfiguration = value; - } - } - } - } -} \ No newline at end of file diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/HttpMethod.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/HttpMethod.cs deleted file mode 100644 index 241fa905e..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/HttpMethod.cs +++ /dev/null @@ -1,33 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -namespace ErsatzTV.Api.Sdk.Client -{ - /// - /// Http methods supported by swagger - /// - public enum HttpMethod - { - /// HTTP GET request. - Get, - /// HTTP POST request. - Post, - /// HTTP PUT request. - Put, - /// HTTP DELETE request. - Delete, - /// HTTP HEAD request. - Head, - /// HTTP OPTIONS request. - Options, - /// HTTP PATCH request. - Patch - } -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/IApiAccessor.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/IApiAccessor.cs deleted file mode 100644 index 61c7e74a3..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/IApiAccessor.cs +++ /dev/null @@ -1,37 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; - -namespace ErsatzTV.Api.Sdk.Client -{ - /// - /// Represents configuration aspects required to interact with the API endpoints. - /// - public interface IApiAccessor - { - /// - /// Gets or sets the configuration object - /// - /// An instance of the Configuration - IReadableConfiguration Configuration { get; set; } - - /// - /// Gets the base path of the API client. - /// - /// The base path - String GetBasePath(); - - /// - /// Provides a factory method hook for the creation of exceptions. - /// - ExceptionFactory ExceptionFactory { get; set; } - } -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/IAsynchronousClient.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/IAsynchronousClient.cs deleted file mode 100644 index 4619807dc..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/IAsynchronousClient.cs +++ /dev/null @@ -1,100 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Threading.Tasks; - -namespace ErsatzTV.Api.Sdk.Client -{ - /// - /// Contract for Asynchronous RESTful API interactions. - /// - /// This interface allows consumers to provide a custom API accessor client. - /// - public interface IAsynchronousClient - { - /// - /// Executes a non-blocking call to some using the GET http verb. - /// - /// The relative path to invoke. - /// The request parameters to pass along to the client. - /// Per-request configurable settings. - /// Cancellation Token to cancel the request. - /// The return type. - /// A task eventually representing the response data, decorated with - Task> GetAsync(String path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// Executes a non-blocking call to some using the POST http verb. - /// - /// The relative path to invoke. - /// The request parameters to pass along to the client. - /// Per-request configurable settings. - /// Cancellation Token to cancel the request. - /// The return type. - /// A task eventually representing the response data, decorated with - Task> PostAsync(String path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// Executes a non-blocking call to some using the PUT http verb. - /// - /// The relative path to invoke. - /// The request parameters to pass along to the client. - /// Per-request configurable settings. - /// Cancellation Token to cancel the request. - /// The return type. - /// A task eventually representing the response data, decorated with - Task> PutAsync(String path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// Executes a non-blocking call to some using the DELETE http verb. - /// - /// The relative path to invoke. - /// The request parameters to pass along to the client. - /// Per-request configurable settings. - /// Cancellation Token to cancel the request. - /// The return type. - /// A task eventually representing the response data, decorated with - Task> DeleteAsync(String path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// Executes a non-blocking call to some using the HEAD http verb. - /// - /// The relative path to invoke. - /// The request parameters to pass along to the client. - /// Per-request configurable settings. - /// Cancellation Token to cancel the request. - /// The return type. - /// A task eventually representing the response data, decorated with - Task> HeadAsync(String path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// Executes a non-blocking call to some using the OPTIONS http verb. - /// - /// The relative path to invoke. - /// The request parameters to pass along to the client. - /// Per-request configurable settings. - /// Cancellation Token to cancel the request. - /// The return type. - /// A task eventually representing the response data, decorated with - Task> OptionsAsync(String path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// Executes a non-blocking call to some using the PATCH http verb. - /// - /// The relative path to invoke. - /// The request parameters to pass along to the client. - /// Per-request configurable settings. - /// Cancellation Token to cancel the request. - /// The return type. - /// A task eventually representing the response data, decorated with - Task> PatchAsync(String path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - } -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/IReadableConfiguration.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/IReadableConfiguration.cs deleted file mode 100644 index 620096df8..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/IReadableConfiguration.cs +++ /dev/null @@ -1,115 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections.Generic; -using System.Net; -using System.Security.Cryptography.X509Certificates; - -namespace ErsatzTV.Api.Sdk.Client -{ - /// - /// Represents a readable-only configuration contract. - /// - public interface IReadableConfiguration - { - /// - /// Gets the access token. - /// - /// Access token. - string AccessToken { get; } - - /// - /// Gets the API key. - /// - /// API key. - IDictionary ApiKey { get; } - - /// - /// Gets the API key prefix. - /// - /// API key prefix. - IDictionary ApiKeyPrefix { get; } - - /// - /// Gets the base path. - /// - /// Base path. - string BasePath { get; } - - /// - /// Gets the date time format. - /// - /// Date time foramt. - string DateTimeFormat { get; } - - /// - /// Gets the default header. - /// - /// Default header. - [Obsolete("Use DefaultHeaders instead.")] - IDictionary DefaultHeader { get; } - - /// - /// Gets the default headers. - /// - /// Default headers. - IDictionary DefaultHeaders { get; } - - /// - /// Gets the temp folder path. - /// - /// Temp folder path. - string TempFolderPath { get; } - - /// - /// Gets the HTTP connection timeout (in milliseconds) - /// - /// HTTP connection timeout. - int Timeout { get; } - - /// - /// Gets the proxy. - /// - /// Proxy. - WebProxy Proxy { get; } - - /// - /// Gets the user agent. - /// - /// User agent. - string UserAgent { get; } - - /// - /// Gets the username. - /// - /// Username. - string Username { get; } - - /// - /// Gets the password. - /// - /// Password. - string Password { get; } - - /// - /// Gets the API key with prefix. - /// - /// API key identifier (authentication scheme). - /// API key with prefix. - string GetApiKeyWithPrefix(string apiKeyIdentifier); - - /// - /// Gets certificate collection to be sent with requests. - /// - /// X509 Certificate collection. - X509CertificateCollection ClientCertificates { get; } - } -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/ISynchronousClient.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/ISynchronousClient.cs deleted file mode 100644 index 108d7833c..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/ISynchronousClient.cs +++ /dev/null @@ -1,93 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.IO; - -namespace ErsatzTV.Api.Sdk.Client -{ - /// - /// Contract for Synchronous RESTful API interactions. - /// - /// This interface allows consumers to provide a custom API accessor client. - /// - public interface ISynchronousClient - { - /// - /// Executes a blocking call to some using the GET http verb. - /// - /// The relative path to invoke. - /// The request parameters to pass along to the client. - /// Per-request configurable settings. - /// The return type. - /// The response data, decorated with - ApiResponse Get(String path, RequestOptions options, IReadableConfiguration configuration = null); - - /// - /// Executes a blocking call to some using the POST http verb. - /// - /// The relative path to invoke. - /// The request parameters to pass along to the client. - /// Per-request configurable settings. - /// The return type. - /// The response data, decorated with - ApiResponse Post(String path, RequestOptions options, IReadableConfiguration configuration = null); - - /// - /// Executes a blocking call to some using the PUT http verb. - /// - /// The relative path to invoke. - /// The request parameters to pass along to the client. - /// Per-request configurable settings. - /// The return type. - /// The response data, decorated with - ApiResponse Put(String path, RequestOptions options, IReadableConfiguration configuration = null); - - /// - /// Executes a blocking call to some using the DELETE http verb. - /// - /// The relative path to invoke. - /// The request parameters to pass along to the client. - /// Per-request configurable settings. - /// The return type. - /// The response data, decorated with - ApiResponse Delete(String path, RequestOptions options, IReadableConfiguration configuration = null); - - /// - /// Executes a blocking call to some using the HEAD http verb. - /// - /// The relative path to invoke. - /// The request parameters to pass along to the client. - /// Per-request configurable settings. - /// The return type. - /// The response data, decorated with - ApiResponse Head(String path, RequestOptions options, IReadableConfiguration configuration = null); - - /// - /// Executes a blocking call to some using the OPTIONS http verb. - /// - /// The relative path to invoke. - /// The request parameters to pass along to the client. - /// Per-request configurable settings. - /// The return type. - /// The response data, decorated with - ApiResponse Options(String path, RequestOptions options, IReadableConfiguration configuration = null); - - /// - /// Executes a blocking call to some using the PATCH http verb. - /// - /// The relative path to invoke. - /// The request parameters to pass along to the client. - /// Per-request configurable settings. - /// The return type. - /// The response data, decorated with - ApiResponse Patch(String path, RequestOptions options, IReadableConfiguration configuration = null); - } -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/Multimap.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/Multimap.cs deleted file mode 100644 index 44b31ee01..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/Multimap.cs +++ /dev/null @@ -1,295 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; - -namespace ErsatzTV.Api.Sdk.Client -{ - /// - /// A dictionary in which one key has many associated values. - /// - /// The type of the key - /// The type of the value associated with the key. - public class Multimap : IDictionary> - { - #region Private Fields - - private readonly Dictionary> _dictionary; - - #endregion Private Fields - - #region Constructors - - /// - /// Empty Constructor. - /// - public Multimap() - { - _dictionary = new Dictionary>(); - } - - /// - /// Constructor with comparer. - /// - /// - public Multimap(IEqualityComparer comparer) - { - _dictionary = new Dictionary>(comparer); - } - - #endregion Constructors - - #region Enumerators - - /// - /// To get the enumerator. - /// - /// Enumerator - public IEnumerator>> GetEnumerator() - { - return _dictionary.GetEnumerator(); - } - - /// - /// To get the enumerator. - /// - /// Enumerator - IEnumerator IEnumerable.GetEnumerator() - { - return _dictionary.GetEnumerator(); - } - - #endregion Enumerators - - #region Public Members - /// - /// Add values to Multimap - /// - /// Key value pair - public void Add(KeyValuePair> item) - { - if (!TryAdd(item.Key, item.Value)) - throw new InvalidOperationException("Could not add values to Multimap."); - } - - /// - /// Add Multimap to Multimap - /// - /// Multimap - public void Add(Multimap multimap) - { - foreach (var item in multimap) - { - if (!TryAdd(item.Key, item.Value)) - throw new InvalidOperationException("Could not add values to Multimap."); - } - } - - /// - /// Clear Multimap - /// - public void Clear() - { - _dictionary.Clear(); - } - - /// - /// Determines whether Multimap contains the specified item. - /// - /// Key value pair - /// Method needs to be implemented - /// true if the Multimap contains the item; otherwise, false. - public bool Contains(KeyValuePair> item) - { - throw new NotImplementedException(); - } - - /// - /// Copy items of the Multimap to an array, - /// starting at a particular array index. - /// - /// The array that is the destination of the items copied - /// from Multimap. The array must have zero-based indexing. - /// The zero-based index in array at which copying begins. - /// Method needs to be implemented - public void CopyTo(KeyValuePair>[] array, int arrayIndex) - { - throw new NotImplementedException(); - } - - /// - /// Removes the specified item from the Multimap. - /// - /// Key value pair - /// true if the item is successfully removed; otherwise, false. - /// Method needs to be implemented - public bool Remove(KeyValuePair> item) - { - throw new NotImplementedException(); - } - - /// - /// Gets the number of items contained in the Multimap. - /// - public int Count => _dictionary.Count; - - /// - /// Gets a value indicating whether the Multimap is read-only. - /// - public bool IsReadOnly => false; - - /// - /// Adds an item with the provided key and value to the Multimap. - /// - /// The object to use as the key of the item to add. - /// The object to use as the value of the item to add. - /// Thrown when couldn't add the value to Multimap. - public void Add(TKey key, IList value) - { - if (value != null && value.Count > 0) - { - if (_dictionary.TryGetValue(key, out var list)) - { - foreach (var k in value) list.Add(k); - } - else - { - list = new List(value); - if (!TryAdd(key, list)) - throw new InvalidOperationException("Could not add values to Multimap."); - } - } - } - - /// - /// Determines whether the Multimap contains an item with the specified key. - /// - /// The key to locate in the Multimap. - /// true if the Multimap contains an item with - /// the key; otherwise, false. - public bool ContainsKey(TKey key) - { - return _dictionary.ContainsKey(key); - } - - /// - /// Removes item with the specified key from the Multimap. - /// - /// The key to locate in the Multimap. - /// true if the item is successfully removed; otherwise, false. - public bool Remove(TKey key) - { - return TryRemove(key, out var _); - } - - /// - /// Gets the value associated with the specified key. - /// - /// The key whose value to get. - /// When this method returns, the value associated with the specified key, if the - /// key is found; otherwise, the default value for the type of the value parameter. - /// This parameter is passed uninitialized. - /// true if the object that implements Multimap contains - /// an item with the specified key; otherwise, false. - public bool TryGetValue(TKey key, out IList value) - { - return _dictionary.TryGetValue(key, out value); - } - - /// - /// Gets or sets the item with the specified key. - /// - /// The key of the item to get or set. - /// The value of the specified key. - public IList this[TKey key] - { - get => _dictionary[key]; - set => _dictionary[key] = value; - } - - /// - /// Gets a System.Collections.Generic.ICollection containing the keys of the Multimap. - /// - public ICollection Keys => _dictionary.Keys; - - /// - /// Gets a System.Collections.Generic.ICollection containing the values of the Multimap. - /// - public ICollection> Values => _dictionary.Values; - - /// - /// Copy the items of the Multimap to an System.Array, - /// starting at a particular System.Array index. - /// - /// The one-dimensional System.Array that is the destination of the items copied - /// from Multimap. The System.Array must have zero-based indexing. - /// The zero-based index in array at which copying begins. - public void CopyTo(Array array, int index) - { - ((ICollection)_dictionary).CopyTo(array, index); - } - - /// - /// Adds an item with the provided key and value to the Multimap. - /// - /// The object to use as the key of the item to add. - /// The object to use as the value of the item to add. - /// Thrown when couldn't add value to Multimap. - public void Add(TKey key, TValue value) - { - if (value != null) - { - if (_dictionary.TryGetValue(key, out var list)) - { - list.Add(value); - } - else - { - list = new List { value }; - if (!TryAdd(key, list)) - throw new InvalidOperationException("Could not add value to Multimap."); - } - } - } - - #endregion Public Members - - #region Private Members - - /** - * Helper method to encapsulate generator differences between dictionary types. - */ - private bool TryRemove(TKey key, out IList value) - { - _dictionary.TryGetValue(key, out value); - return _dictionary.Remove(key); - } - - /** - * Helper method to encapsulate generator differences between dictionary types. - */ - private bool TryAdd(TKey key, IList value) - { - try - { - _dictionary.Add(key, value); - } - catch (ArgumentException) - { - return false; - } - - return true; - } - #endregion Private Members - } -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/OpenAPIDateConverter.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/OpenAPIDateConverter.cs deleted file mode 100644 index 8eecaccfa..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/OpenAPIDateConverter.cs +++ /dev/null @@ -1,29 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - -using Newtonsoft.Json.Converters; - -namespace ErsatzTV.Api.Sdk.Client -{ - /// - /// Formatter for 'date' openapi formats ss defined by full-date - RFC3339 - /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types - /// - public class OpenAPIDateConverter : IsoDateTimeConverter - { - /// - /// Initializes a new instance of the class. - /// - public OpenAPIDateConverter() - { - // full-date = date-fullyear "-" date-month "-" date-mday - DateTimeFormat = "yyyy-MM-dd"; - } - } -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/RequestOptions.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/RequestOptions.cs deleted file mode 100644 index 296e589cc..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/RequestOptions.cs +++ /dev/null @@ -1,74 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections.Generic; -using System.IO; -using System.Net; - -namespace ErsatzTV.Api.Sdk.Client -{ - /// - /// A container for generalized request inputs. This type allows consumers to extend the request functionality - /// by abstracting away from the default (built-in) request framework (e.g. RestSharp). - /// - public class RequestOptions - { - /// - /// Parameters to be bound to path parts of the Request's URL - /// - public Dictionary PathParameters { get; set; } - - /// - /// Query parameters to be applied to the request. - /// Keys may have 1 or more values associated. - /// - public Multimap QueryParameters { get; set; } - - /// - /// Header parameters to be applied to to the request. - /// Keys may have 1 or more values associated. - /// - public Multimap HeaderParameters { get; set; } - - /// - /// Form parameters to be sent along with the request. - /// - public Dictionary FormParameters { get; set; } - - /// - /// File parameters to be sent along with the request. - /// - public Dictionary FileParameters { get; set; } - - /// - /// Cookies to be sent along with the request. - /// - public List Cookies { get; set; } - - /// - /// Any data associated with a request body. - /// - public Object Data { get; set; } - - /// - /// Constructs a new instance of - /// - public RequestOptions() - { - PathParameters = new Dictionary(); - QueryParameters = new Multimap(); - HeaderParameters = new Multimap(); - FormParameters = new Dictionary(); - FileParameters = new Dictionary(); - Cookies = new List(); - } - } -} \ No newline at end of file diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/RetryConfiguration.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/RetryConfiguration.cs deleted file mode 100644 index a2f789660..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Client/RetryConfiguration.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Polly; -using RestSharp; - -namespace ErsatzTV.Api.Sdk.Client -{ - /// - /// Configuration class to set the polly retry policies to be applied to the requests. - /// - public class RetryConfiguration - { - /// - /// Retry policy - /// - public static Policy RetryPolicy { get; set; } - - /// - /// Async retry policy - /// - public static AsyncPolicy AsyncRetryPolicy { get; set; } - } -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/ErsatzTV.Api.Sdk.csproj b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/ErsatzTV.Api.Sdk.csproj deleted file mode 100644 index 13c64ada0..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/ErsatzTV.Api.Sdk.csproj +++ /dev/null @@ -1,30 +0,0 @@ - - - - false - netcoreapp3.1 - ErsatzTV.Api.Sdk - ErsatzTV.Api.Sdk - Library - OpenAPI - OpenAPI - OpenAPI Library - A library generated from a OpenAPI doc - No Copyright - ErsatzTV.Api.Sdk - 1.0.0 - bin\$(Configuration)\$(TargetFramework)\ErsatzTV.Api.Sdk.xml - https://github.com/GIT_USER_ID/GIT_REPO_ID.git - git - Minor update - - - - - - - - - - - diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/AbstractOpenAPISchema.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/AbstractOpenAPISchema.cs deleted file mode 100644 index 70b23257c..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/AbstractOpenAPISchema.cs +++ /dev/null @@ -1,76 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// Abstract base class for oneOf, anyOf schemas in the OpenAPI specification - /// - public abstract partial class AbstractOpenAPISchema - { - /// - /// Custom JSON serializer - /// - static public readonly JsonSerializerSettings SerializerSettings = new JsonSerializerSettings - { - // OpenAPI generated types generally hide default constructors. - ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor, - MissingMemberHandling = MissingMemberHandling.Error, - ContractResolver = new DefaultContractResolver - { - NamingStrategy = new CamelCaseNamingStrategy - { - OverrideSpecifiedNames = false - } - } - }; - - /// - /// Custom JSON serializer for objects with additional properties - /// - static public readonly JsonSerializerSettings AdditionalPropertiesSerializerSettings = new JsonSerializerSettings - { - // OpenAPI generated types generally hide default constructors. - ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor, - MissingMemberHandling = MissingMemberHandling.Ignore, - ContractResolver = new DefaultContractResolver - { - NamingStrategy = new CamelCaseNamingStrategy - { - OverrideSpecifiedNames = false - } - } - }; - - /// - /// Gets or Sets the actual instance - /// - public abstract Object ActualInstance { get; set; } - - /// - /// Gets or Sets IsNullable to indicate whether the instance is nullable - /// - public bool IsNullable { get; protected set; } - - /// - /// Gets or Sets the schema type, which can be either `oneOf` or `anyOf` - /// - public string SchemaType { get; protected set; } - - /// - /// Converts the instance into JSON string. - /// - public abstract string ToJson(); - } -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/AddProgramScheduleItem.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/AddProgramScheduleItem.cs deleted file mode 100644 index b0d0100af..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/AddProgramScheduleItem.cs +++ /dev/null @@ -1,227 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// AddProgramScheduleItem - /// - [DataContract(Name = "AddProgramScheduleItem")] - public partial class AddProgramScheduleItem : IEquatable, IValidatableObject - { - /// - /// Gets or Sets StartType - /// - [DataMember(Name = "startType", EmitDefaultValue = false)] - public StartType? StartType { get; set; } - /// - /// Gets or Sets PlayoutMode - /// - [DataMember(Name = "playoutMode", EmitDefaultValue = false)] - public PlayoutMode? PlayoutMode { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// programScheduleId. - /// startType. - /// startTime. - /// playoutMode. - /// mediaCollectionId. - /// multipleCount. - /// playoutDuration. - /// offlineTail. - public AddProgramScheduleItem(int programScheduleId = default(int), StartType? startType = default(StartType?), string startTime = default(string), PlayoutMode? playoutMode = default(PlayoutMode?), int mediaCollectionId = default(int), int? multipleCount = default(int?), string playoutDuration = default(string), bool? offlineTail = default(bool?)) - { - this.ProgramScheduleId = programScheduleId; - this.StartType = startType; - this.StartTime = startTime; - this.PlayoutMode = playoutMode; - this.MediaCollectionId = mediaCollectionId; - this.MultipleCount = multipleCount; - this.PlayoutDuration = playoutDuration; - this.OfflineTail = offlineTail; - } - - /// - /// Gets or Sets ProgramScheduleId - /// - [DataMember(Name = "programScheduleId", EmitDefaultValue = false)] - public int ProgramScheduleId { get; set; } - - /// - /// Gets or Sets StartTime - /// - [DataMember(Name = "startTime", EmitDefaultValue = true)] - public string StartTime { get; set; } - - /// - /// Gets or Sets MediaCollectionId - /// - [DataMember(Name = "mediaCollectionId", EmitDefaultValue = false)] - public int MediaCollectionId { get; set; } - - /// - /// Gets or Sets MultipleCount - /// - [DataMember(Name = "multipleCount", EmitDefaultValue = true)] - public int? MultipleCount { get; set; } - - /// - /// Gets or Sets PlayoutDuration - /// - [DataMember(Name = "playoutDuration", EmitDefaultValue = true)] - public string PlayoutDuration { get; set; } - - /// - /// Gets or Sets OfflineTail - /// - [DataMember(Name = "offlineTail", EmitDefaultValue = true)] - public bool? OfflineTail { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("class AddProgramScheduleItem {\n"); - sb.Append(" ProgramScheduleId: ").Append(ProgramScheduleId).Append("\n"); - sb.Append(" StartType: ").Append(StartType).Append("\n"); - sb.Append(" StartTime: ").Append(StartTime).Append("\n"); - sb.Append(" PlayoutMode: ").Append(PlayoutMode).Append("\n"); - sb.Append(" MediaCollectionId: ").Append(MediaCollectionId).Append("\n"); - sb.Append(" MultipleCount: ").Append(MultipleCount).Append("\n"); - sb.Append(" PlayoutDuration: ").Append(PlayoutDuration).Append("\n"); - sb.Append(" OfflineTail: ").Append(OfflineTail).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as AddProgramScheduleItem); - } - - /// - /// Returns true if AddProgramScheduleItem instances are equal - /// - /// Instance of AddProgramScheduleItem to be compared - /// Boolean - public bool Equals(AddProgramScheduleItem input) - { - if (input == null) - return false; - - return - ( - this.ProgramScheduleId == input.ProgramScheduleId || - this.ProgramScheduleId.Equals(input.ProgramScheduleId) - ) && - ( - this.StartType == input.StartType || - this.StartType.Equals(input.StartType) - ) && - ( - this.StartTime == input.StartTime || - (this.StartTime != null && - this.StartTime.Equals(input.StartTime)) - ) && - ( - this.PlayoutMode == input.PlayoutMode || - this.PlayoutMode.Equals(input.PlayoutMode) - ) && - ( - this.MediaCollectionId == input.MediaCollectionId || - this.MediaCollectionId.Equals(input.MediaCollectionId) - ) && - ( - this.MultipleCount == input.MultipleCount || - (this.MultipleCount != null && - this.MultipleCount.Equals(input.MultipleCount)) - ) && - ( - this.PlayoutDuration == input.PlayoutDuration || - (this.PlayoutDuration != null && - this.PlayoutDuration.Equals(input.PlayoutDuration)) - ) && - ( - this.OfflineTail == input.OfflineTail || - (this.OfflineTail != null && - this.OfflineTail.Equals(input.OfflineTail)) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.ProgramScheduleId.GetHashCode(); - hashCode = hashCode * 59 + this.StartType.GetHashCode(); - if (this.StartTime != null) - hashCode = hashCode * 59 + this.StartTime.GetHashCode(); - hashCode = hashCode * 59 + this.PlayoutMode.GetHashCode(); - hashCode = hashCode * 59 + this.MediaCollectionId.GetHashCode(); - if (this.MultipleCount != null) - hashCode = hashCode * 59 + this.MultipleCount.GetHashCode(); - if (this.PlayoutDuration != null) - hashCode = hashCode * 59 + this.PlayoutDuration.GetHashCode(); - if (this.OfflineTail != null) - hashCode = hashCode * 59 + this.OfflineTail.GetHashCode(); - return hashCode; - } - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ChannelViewModel.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ChannelViewModel.cs deleted file mode 100644 index 09a44d295..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ChannelViewModel.cs +++ /dev/null @@ -1,196 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// ChannelViewModel - /// - [DataContract(Name = "ChannelViewModel")] - public partial class ChannelViewModel : IEquatable, IValidatableObject - { - /// - /// Gets or Sets StreamingMode - /// - [DataMember(Name = "streamingMode", EmitDefaultValue = false)] - public StreamingMode? StreamingMode { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// id. - /// number. - /// name. - /// ffmpegProfileId. - /// logo. - /// streamingMode. - public ChannelViewModel(int id = default(int), int number = default(int), string name = default(string), int ffmpegProfileId = default(int), string logo = default(string), StreamingMode? streamingMode = default(StreamingMode?)) - { - this.Id = id; - this.Number = number; - this.Name = name; - this.FfmpegProfileId = ffmpegProfileId; - this.Logo = logo; - this.StreamingMode = streamingMode; - } - - /// - /// Gets or Sets Id - /// - [DataMember(Name = "id", EmitDefaultValue = false)] - public int Id { get; set; } - - /// - /// Gets or Sets Number - /// - [DataMember(Name = "number", EmitDefaultValue = false)] - public int Number { get; set; } - - /// - /// Gets or Sets Name - /// - [DataMember(Name = "name", EmitDefaultValue = true)] - public string Name { get; set; } - - /// - /// Gets or Sets FfmpegProfileId - /// - [DataMember(Name = "ffmpegProfileId", EmitDefaultValue = false)] - public int FfmpegProfileId { get; set; } - - /// - /// Gets or Sets Logo - /// - [DataMember(Name = "logo", EmitDefaultValue = true)] - public string Logo { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("class ChannelViewModel {\n"); - sb.Append(" Id: ").Append(Id).Append("\n"); - sb.Append(" Number: ").Append(Number).Append("\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append(" FfmpegProfileId: ").Append(FfmpegProfileId).Append("\n"); - sb.Append(" Logo: ").Append(Logo).Append("\n"); - sb.Append(" StreamingMode: ").Append(StreamingMode).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as ChannelViewModel); - } - - /// - /// Returns true if ChannelViewModel instances are equal - /// - /// Instance of ChannelViewModel to be compared - /// Boolean - public bool Equals(ChannelViewModel input) - { - if (input == null) - return false; - - return - ( - this.Id == input.Id || - this.Id.Equals(input.Id) - ) && - ( - this.Number == input.Number || - this.Number.Equals(input.Number) - ) && - ( - this.Name == input.Name || - (this.Name != null && - this.Name.Equals(input.Name)) - ) && - ( - this.FfmpegProfileId == input.FfmpegProfileId || - this.FfmpegProfileId.Equals(input.FfmpegProfileId) - ) && - ( - this.Logo == input.Logo || - (this.Logo != null && - this.Logo.Equals(input.Logo)) - ) && - ( - this.StreamingMode == input.StreamingMode || - this.StreamingMode.Equals(input.StreamingMode) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.Id.GetHashCode(); - hashCode = hashCode * 59 + this.Number.GetHashCode(); - if (this.Name != null) - hashCode = hashCode * 59 + this.Name.GetHashCode(); - hashCode = hashCode * 59 + this.FfmpegProfileId.GetHashCode(); - if (this.Logo != null) - hashCode = hashCode * 59 + this.Logo.GetHashCode(); - hashCode = hashCode * 59 + this.StreamingMode.GetHashCode(); - return hashCode; - } - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/CreateChannel.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/CreateChannel.cs deleted file mode 100644 index 8f0a5ef75..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/CreateChannel.cs +++ /dev/null @@ -1,182 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// CreateChannel - /// - [DataContract(Name = "CreateChannel")] - public partial class CreateChannel : IEquatable, IValidatableObject - { - /// - /// Gets or Sets StreamingMode - /// - [DataMember(Name = "streamingMode", EmitDefaultValue = false)] - public StreamingMode? StreamingMode { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// name. - /// number. - /// ffmpegProfileId. - /// logo. - /// streamingMode. - public CreateChannel(string name = default(string), int number = default(int), int ffmpegProfileId = default(int), string logo = default(string), StreamingMode? streamingMode = default(StreamingMode?)) - { - this.Name = name; - this.Number = number; - this.FfmpegProfileId = ffmpegProfileId; - this.Logo = logo; - this.StreamingMode = streamingMode; - } - - /// - /// Gets or Sets Name - /// - [DataMember(Name = "name", EmitDefaultValue = true)] - public string Name { get; set; } - - /// - /// Gets or Sets Number - /// - [DataMember(Name = "number", EmitDefaultValue = false)] - public int Number { get; set; } - - /// - /// Gets or Sets FfmpegProfileId - /// - [DataMember(Name = "ffmpegProfileId", EmitDefaultValue = false)] - public int FfmpegProfileId { get; set; } - - /// - /// Gets or Sets Logo - /// - [DataMember(Name = "logo", EmitDefaultValue = true)] - public string Logo { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("class CreateChannel {\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append(" Number: ").Append(Number).Append("\n"); - sb.Append(" FfmpegProfileId: ").Append(FfmpegProfileId).Append("\n"); - sb.Append(" Logo: ").Append(Logo).Append("\n"); - sb.Append(" StreamingMode: ").Append(StreamingMode).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as CreateChannel); - } - - /// - /// Returns true if CreateChannel instances are equal - /// - /// Instance of CreateChannel to be compared - /// Boolean - public bool Equals(CreateChannel input) - { - if (input == null) - return false; - - return - ( - this.Name == input.Name || - (this.Name != null && - this.Name.Equals(input.Name)) - ) && - ( - this.Number == input.Number || - this.Number.Equals(input.Number) - ) && - ( - this.FfmpegProfileId == input.FfmpegProfileId || - this.FfmpegProfileId.Equals(input.FfmpegProfileId) - ) && - ( - this.Logo == input.Logo || - (this.Logo != null && - this.Logo.Equals(input.Logo)) - ) && - ( - this.StreamingMode == input.StreamingMode || - this.StreamingMode.Equals(input.StreamingMode) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.Name != null) - hashCode = hashCode * 59 + this.Name.GetHashCode(); - hashCode = hashCode * 59 + this.Number.GetHashCode(); - hashCode = hashCode * 59 + this.FfmpegProfileId.GetHashCode(); - if (this.Logo != null) - hashCode = hashCode * 59 + this.Logo.GetHashCode(); - hashCode = hashCode * 59 + this.StreamingMode.GetHashCode(); - return hashCode; - } - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/CreateFFmpegProfile.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/CreateFFmpegProfile.cs deleted file mode 100644 index 6c1211c10..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/CreateFFmpegProfile.cs +++ /dev/null @@ -1,353 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// CreateFFmpegProfile - /// - [DataContract(Name = "CreateFFmpegProfile")] - public partial class CreateFFmpegProfile : IEquatable, IValidatableObject - { - /// - /// Initializes a new instance of the class. - /// - /// name. - /// threadCount. - /// transcode. - /// resolutionId. - /// normalizeResolution. - /// videoCodec. - /// normalizeVideoCodec. - /// videoBitrate. - /// videoBufferSize. - /// audioCodec. - /// normalizeAudioCodec. - /// audioBitrate. - /// audioBufferSize. - /// audioVolume. - /// audioChannels. - /// audioSampleRate. - /// normalizeAudio. - public CreateFFmpegProfile(string name = default(string), int threadCount = default(int), bool transcode = default(bool), int resolutionId = default(int), bool normalizeResolution = default(bool), string videoCodec = default(string), bool normalizeVideoCodec = default(bool), int videoBitrate = default(int), int videoBufferSize = default(int), string audioCodec = default(string), bool normalizeAudioCodec = default(bool), int audioBitrate = default(int), int audioBufferSize = default(int), int audioVolume = default(int), int audioChannels = default(int), int audioSampleRate = default(int), bool normalizeAudio = default(bool)) - { - this.Name = name; - this.ThreadCount = threadCount; - this.Transcode = transcode; - this.ResolutionId = resolutionId; - this.NormalizeResolution = normalizeResolution; - this.VideoCodec = videoCodec; - this.NormalizeVideoCodec = normalizeVideoCodec; - this.VideoBitrate = videoBitrate; - this.VideoBufferSize = videoBufferSize; - this.AudioCodec = audioCodec; - this.NormalizeAudioCodec = normalizeAudioCodec; - this.AudioBitrate = audioBitrate; - this.AudioBufferSize = audioBufferSize; - this.AudioVolume = audioVolume; - this.AudioChannels = audioChannels; - this.AudioSampleRate = audioSampleRate; - this.NormalizeAudio = normalizeAudio; - } - - /// - /// Gets or Sets Name - /// - [DataMember(Name = "name", EmitDefaultValue = true)] - public string Name { get; set; } - - /// - /// Gets or Sets ThreadCount - /// - [DataMember(Name = "threadCount", EmitDefaultValue = false)] - public int ThreadCount { get; set; } - - /// - /// Gets or Sets Transcode - /// - [DataMember(Name = "transcode", EmitDefaultValue = false)] - public bool Transcode { get; set; } - - /// - /// Gets or Sets ResolutionId - /// - [DataMember(Name = "resolutionId", EmitDefaultValue = false)] - public int ResolutionId { get; set; } - - /// - /// Gets or Sets NormalizeResolution - /// - [DataMember(Name = "normalizeResolution", EmitDefaultValue = false)] - public bool NormalizeResolution { get; set; } - - /// - /// Gets or Sets VideoCodec - /// - [DataMember(Name = "videoCodec", EmitDefaultValue = true)] - public string VideoCodec { get; set; } - - /// - /// Gets or Sets NormalizeVideoCodec - /// - [DataMember(Name = "normalizeVideoCodec", EmitDefaultValue = false)] - public bool NormalizeVideoCodec { get; set; } - - /// - /// Gets or Sets VideoBitrate - /// - [DataMember(Name = "videoBitrate", EmitDefaultValue = false)] - public int VideoBitrate { get; set; } - - /// - /// Gets or Sets VideoBufferSize - /// - [DataMember(Name = "videoBufferSize", EmitDefaultValue = false)] - public int VideoBufferSize { get; set; } - - /// - /// Gets or Sets AudioCodec - /// - [DataMember(Name = "audioCodec", EmitDefaultValue = true)] - public string AudioCodec { get; set; } - - /// - /// Gets or Sets NormalizeAudioCodec - /// - [DataMember(Name = "normalizeAudioCodec", EmitDefaultValue = false)] - public bool NormalizeAudioCodec { get; set; } - - /// - /// Gets or Sets AudioBitrate - /// - [DataMember(Name = "audioBitrate", EmitDefaultValue = false)] - public int AudioBitrate { get; set; } - - /// - /// Gets or Sets AudioBufferSize - /// - [DataMember(Name = "audioBufferSize", EmitDefaultValue = false)] - public int AudioBufferSize { get; set; } - - /// - /// Gets or Sets AudioVolume - /// - [DataMember(Name = "audioVolume", EmitDefaultValue = false)] - public int AudioVolume { get; set; } - - /// - /// Gets or Sets AudioChannels - /// - [DataMember(Name = "audioChannels", EmitDefaultValue = false)] - public int AudioChannels { get; set; } - - /// - /// Gets or Sets AudioSampleRate - /// - [DataMember(Name = "audioSampleRate", EmitDefaultValue = false)] - public int AudioSampleRate { get; set; } - - /// - /// Gets or Sets NormalizeAudio - /// - [DataMember(Name = "normalizeAudio", EmitDefaultValue = false)] - public bool NormalizeAudio { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("class CreateFFmpegProfile {\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append(" ThreadCount: ").Append(ThreadCount).Append("\n"); - sb.Append(" Transcode: ").Append(Transcode).Append("\n"); - sb.Append(" ResolutionId: ").Append(ResolutionId).Append("\n"); - sb.Append(" NormalizeResolution: ").Append(NormalizeResolution).Append("\n"); - sb.Append(" VideoCodec: ").Append(VideoCodec).Append("\n"); - sb.Append(" NormalizeVideoCodec: ").Append(NormalizeVideoCodec).Append("\n"); - sb.Append(" VideoBitrate: ").Append(VideoBitrate).Append("\n"); - sb.Append(" VideoBufferSize: ").Append(VideoBufferSize).Append("\n"); - sb.Append(" AudioCodec: ").Append(AudioCodec).Append("\n"); - sb.Append(" NormalizeAudioCodec: ").Append(NormalizeAudioCodec).Append("\n"); - sb.Append(" AudioBitrate: ").Append(AudioBitrate).Append("\n"); - sb.Append(" AudioBufferSize: ").Append(AudioBufferSize).Append("\n"); - sb.Append(" AudioVolume: ").Append(AudioVolume).Append("\n"); - sb.Append(" AudioChannels: ").Append(AudioChannels).Append("\n"); - sb.Append(" AudioSampleRate: ").Append(AudioSampleRate).Append("\n"); - sb.Append(" NormalizeAudio: ").Append(NormalizeAudio).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as CreateFFmpegProfile); - } - - /// - /// Returns true if CreateFFmpegProfile instances are equal - /// - /// Instance of CreateFFmpegProfile to be compared - /// Boolean - public bool Equals(CreateFFmpegProfile input) - { - if (input == null) - return false; - - return - ( - this.Name == input.Name || - (this.Name != null && - this.Name.Equals(input.Name)) - ) && - ( - this.ThreadCount == input.ThreadCount || - this.ThreadCount.Equals(input.ThreadCount) - ) && - ( - this.Transcode == input.Transcode || - this.Transcode.Equals(input.Transcode) - ) && - ( - this.ResolutionId == input.ResolutionId || - this.ResolutionId.Equals(input.ResolutionId) - ) && - ( - this.NormalizeResolution == input.NormalizeResolution || - this.NormalizeResolution.Equals(input.NormalizeResolution) - ) && - ( - this.VideoCodec == input.VideoCodec || - (this.VideoCodec != null && - this.VideoCodec.Equals(input.VideoCodec)) - ) && - ( - this.NormalizeVideoCodec == input.NormalizeVideoCodec || - this.NormalizeVideoCodec.Equals(input.NormalizeVideoCodec) - ) && - ( - this.VideoBitrate == input.VideoBitrate || - this.VideoBitrate.Equals(input.VideoBitrate) - ) && - ( - this.VideoBufferSize == input.VideoBufferSize || - this.VideoBufferSize.Equals(input.VideoBufferSize) - ) && - ( - this.AudioCodec == input.AudioCodec || - (this.AudioCodec != null && - this.AudioCodec.Equals(input.AudioCodec)) - ) && - ( - this.NormalizeAudioCodec == input.NormalizeAudioCodec || - this.NormalizeAudioCodec.Equals(input.NormalizeAudioCodec) - ) && - ( - this.AudioBitrate == input.AudioBitrate || - this.AudioBitrate.Equals(input.AudioBitrate) - ) && - ( - this.AudioBufferSize == input.AudioBufferSize || - this.AudioBufferSize.Equals(input.AudioBufferSize) - ) && - ( - this.AudioVolume == input.AudioVolume || - this.AudioVolume.Equals(input.AudioVolume) - ) && - ( - this.AudioChannels == input.AudioChannels || - this.AudioChannels.Equals(input.AudioChannels) - ) && - ( - this.AudioSampleRate == input.AudioSampleRate || - this.AudioSampleRate.Equals(input.AudioSampleRate) - ) && - ( - this.NormalizeAudio == input.NormalizeAudio || - this.NormalizeAudio.Equals(input.NormalizeAudio) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.Name != null) - hashCode = hashCode * 59 + this.Name.GetHashCode(); - hashCode = hashCode * 59 + this.ThreadCount.GetHashCode(); - hashCode = hashCode * 59 + this.Transcode.GetHashCode(); - hashCode = hashCode * 59 + this.ResolutionId.GetHashCode(); - hashCode = hashCode * 59 + this.NormalizeResolution.GetHashCode(); - if (this.VideoCodec != null) - hashCode = hashCode * 59 + this.VideoCodec.GetHashCode(); - hashCode = hashCode * 59 + this.NormalizeVideoCodec.GetHashCode(); - hashCode = hashCode * 59 + this.VideoBitrate.GetHashCode(); - hashCode = hashCode * 59 + this.VideoBufferSize.GetHashCode(); - if (this.AudioCodec != null) - hashCode = hashCode * 59 + this.AudioCodec.GetHashCode(); - hashCode = hashCode * 59 + this.NormalizeAudioCodec.GetHashCode(); - hashCode = hashCode * 59 + this.AudioBitrate.GetHashCode(); - hashCode = hashCode * 59 + this.AudioBufferSize.GetHashCode(); - hashCode = hashCode * 59 + this.AudioVolume.GetHashCode(); - hashCode = hashCode * 59 + this.AudioChannels.GetHashCode(); - hashCode = hashCode * 59 + this.AudioSampleRate.GetHashCode(); - hashCode = hashCode * 59 + this.NormalizeAudio.GetHashCode(); - return hashCode; - } - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/CreatePlayout.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/CreatePlayout.cs deleted file mode 100644 index be152cef3..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/CreatePlayout.cs +++ /dev/null @@ -1,150 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// CreatePlayout - /// - [DataContract(Name = "CreatePlayout")] - public partial class CreatePlayout : IEquatable, IValidatableObject - { - /// - /// Gets or Sets ProgramSchedulePlayoutType - /// - [DataMember(Name = "programSchedulePlayoutType", EmitDefaultValue = false)] - public ProgramSchedulePlayoutType? ProgramSchedulePlayoutType { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// channelId. - /// programScheduleId. - /// programSchedulePlayoutType. - public CreatePlayout(int channelId = default(int), int programScheduleId = default(int), ProgramSchedulePlayoutType? programSchedulePlayoutType = default(ProgramSchedulePlayoutType?)) - { - this.ChannelId = channelId; - this.ProgramScheduleId = programScheduleId; - this.ProgramSchedulePlayoutType = programSchedulePlayoutType; - } - - /// - /// Gets or Sets ChannelId - /// - [DataMember(Name = "channelId", EmitDefaultValue = false)] - public int ChannelId { get; set; } - - /// - /// Gets or Sets ProgramScheduleId - /// - [DataMember(Name = "programScheduleId", EmitDefaultValue = false)] - public int ProgramScheduleId { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("class CreatePlayout {\n"); - sb.Append(" ChannelId: ").Append(ChannelId).Append("\n"); - sb.Append(" ProgramScheduleId: ").Append(ProgramScheduleId).Append("\n"); - sb.Append(" ProgramSchedulePlayoutType: ").Append(ProgramSchedulePlayoutType).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as CreatePlayout); - } - - /// - /// Returns true if CreatePlayout instances are equal - /// - /// Instance of CreatePlayout to be compared - /// Boolean - public bool Equals(CreatePlayout input) - { - if (input == null) - return false; - - return - ( - this.ChannelId == input.ChannelId || - this.ChannelId.Equals(input.ChannelId) - ) && - ( - this.ProgramScheduleId == input.ProgramScheduleId || - this.ProgramScheduleId.Equals(input.ProgramScheduleId) - ) && - ( - this.ProgramSchedulePlayoutType == input.ProgramSchedulePlayoutType || - this.ProgramSchedulePlayoutType.Equals(input.ProgramSchedulePlayoutType) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.ChannelId.GetHashCode(); - hashCode = hashCode * 59 + this.ProgramScheduleId.GetHashCode(); - hashCode = hashCode * 59 + this.ProgramSchedulePlayoutType.GetHashCode(); - return hashCode; - } - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/CreateProgramSchedule.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/CreateProgramSchedule.cs deleted file mode 100644 index 9bbef9c2d..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/CreateProgramSchedule.cs +++ /dev/null @@ -1,138 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// CreateProgramSchedule - /// - [DataContract(Name = "CreateProgramSchedule")] - public partial class CreateProgramSchedule : IEquatable, IValidatableObject - { - /// - /// Gets or Sets MediaCollectionPlaybackOrder - /// - [DataMember(Name = "mediaCollectionPlaybackOrder", EmitDefaultValue = false)] - public PlaybackOrder? MediaCollectionPlaybackOrder { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// name. - /// mediaCollectionPlaybackOrder. - public CreateProgramSchedule(string name = default(string), PlaybackOrder? mediaCollectionPlaybackOrder = default(PlaybackOrder?)) - { - this.Name = name; - this.MediaCollectionPlaybackOrder = mediaCollectionPlaybackOrder; - } - - /// - /// Gets or Sets Name - /// - [DataMember(Name = "name", EmitDefaultValue = true)] - public string Name { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("class CreateProgramSchedule {\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append(" MediaCollectionPlaybackOrder: ").Append(MediaCollectionPlaybackOrder).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as CreateProgramSchedule); - } - - /// - /// Returns true if CreateProgramSchedule instances are equal - /// - /// Instance of CreateProgramSchedule to be compared - /// Boolean - public bool Equals(CreateProgramSchedule input) - { - if (input == null) - return false; - - return - ( - this.Name == input.Name || - (this.Name != null && - this.Name.Equals(input.Name)) - ) && - ( - this.MediaCollectionPlaybackOrder == input.MediaCollectionPlaybackOrder || - this.MediaCollectionPlaybackOrder.Equals(input.MediaCollectionPlaybackOrder) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.Name != null) - hashCode = hashCode * 59 + this.Name.GetHashCode(); - hashCode = hashCode * 59 + this.MediaCollectionPlaybackOrder.GetHashCode(); - return hashCode; - } - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/CreateSimpleMediaCollection.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/CreateSimpleMediaCollection.cs deleted file mode 100644 index fae362420..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/CreateSimpleMediaCollection.cs +++ /dev/null @@ -1,125 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// CreateSimpleMediaCollection - /// - [DataContract(Name = "CreateSimpleMediaCollection")] - public partial class CreateSimpleMediaCollection : IEquatable, IValidatableObject - { - /// - /// Initializes a new instance of the class. - /// - /// name. - public CreateSimpleMediaCollection(string name = default(string)) - { - this.Name = name; - } - - /// - /// Gets or Sets Name - /// - [DataMember(Name = "name", EmitDefaultValue = true)] - public string Name { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("class CreateSimpleMediaCollection {\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as CreateSimpleMediaCollection); - } - - /// - /// Returns true if CreateSimpleMediaCollection instances are equal - /// - /// Instance of CreateSimpleMediaCollection to be compared - /// Boolean - public bool Equals(CreateSimpleMediaCollection input) - { - if (input == null) - return false; - - return - ( - this.Name == input.Name || - (this.Name != null && - this.Name.Equals(input.Name)) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.Name != null) - hashCode = hashCode * 59 + this.Name.GetHashCode(); - return hashCode; - } - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/DeleteChannel.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/DeleteChannel.cs deleted file mode 100644 index 0c13d6faa..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/DeleteChannel.cs +++ /dev/null @@ -1,123 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// DeleteChannel - /// - [DataContract(Name = "DeleteChannel")] - public partial class DeleteChannel : IEquatable, IValidatableObject - { - /// - /// Initializes a new instance of the class. - /// - /// channelId. - public DeleteChannel(int channelId = default(int)) - { - this.ChannelId = channelId; - } - - /// - /// Gets or Sets ChannelId - /// - [DataMember(Name = "channelId", EmitDefaultValue = false)] - public int ChannelId { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("class DeleteChannel {\n"); - sb.Append(" ChannelId: ").Append(ChannelId).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as DeleteChannel); - } - - /// - /// Returns true if DeleteChannel instances are equal - /// - /// Instance of DeleteChannel to be compared - /// Boolean - public bool Equals(DeleteChannel input) - { - if (input == null) - return false; - - return - ( - this.ChannelId == input.ChannelId || - this.ChannelId.Equals(input.ChannelId) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.ChannelId.GetHashCode(); - return hashCode; - } - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/DeleteFFmpegProfile.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/DeleteFFmpegProfile.cs deleted file mode 100644 index 63738083b..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/DeleteFFmpegProfile.cs +++ /dev/null @@ -1,123 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// DeleteFFmpegProfile - /// - [DataContract(Name = "DeleteFFmpegProfile")] - public partial class DeleteFFmpegProfile : IEquatable, IValidatableObject - { - /// - /// Initializes a new instance of the class. - /// - /// ffmpegProfileId. - public DeleteFFmpegProfile(int ffmpegProfileId = default(int)) - { - this.FfmpegProfileId = ffmpegProfileId; - } - - /// - /// Gets or Sets FfmpegProfileId - /// - [DataMember(Name = "ffmpegProfileId", EmitDefaultValue = false)] - public int FfmpegProfileId { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("class DeleteFFmpegProfile {\n"); - sb.Append(" FfmpegProfileId: ").Append(FfmpegProfileId).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as DeleteFFmpegProfile); - } - - /// - /// Returns true if DeleteFFmpegProfile instances are equal - /// - /// Instance of DeleteFFmpegProfile to be compared - /// Boolean - public bool Equals(DeleteFFmpegProfile input) - { - if (input == null) - return false; - - return - ( - this.FfmpegProfileId == input.FfmpegProfileId || - this.FfmpegProfileId.Equals(input.FfmpegProfileId) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.FfmpegProfileId.GetHashCode(); - return hashCode; - } - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/DeletePlayout.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/DeletePlayout.cs deleted file mode 100644 index c4c7c11b3..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/DeletePlayout.cs +++ /dev/null @@ -1,123 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// DeletePlayout - /// - [DataContract(Name = "DeletePlayout")] - public partial class DeletePlayout : IEquatable, IValidatableObject - { - /// - /// Initializes a new instance of the class. - /// - /// playoutId. - public DeletePlayout(int playoutId = default(int)) - { - this.PlayoutId = playoutId; - } - - /// - /// Gets or Sets PlayoutId - /// - [DataMember(Name = "playoutId", EmitDefaultValue = false)] - public int PlayoutId { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("class DeletePlayout {\n"); - sb.Append(" PlayoutId: ").Append(PlayoutId).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as DeletePlayout); - } - - /// - /// Returns true if DeletePlayout instances are equal - /// - /// Instance of DeletePlayout to be compared - /// Boolean - public bool Equals(DeletePlayout input) - { - if (input == null) - return false; - - return - ( - this.PlayoutId == input.PlayoutId || - this.PlayoutId.Equals(input.PlayoutId) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.PlayoutId.GetHashCode(); - return hashCode; - } - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/DeleteProgramSchedule.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/DeleteProgramSchedule.cs deleted file mode 100644 index a0c68ce32..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/DeleteProgramSchedule.cs +++ /dev/null @@ -1,123 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// DeleteProgramSchedule - /// - [DataContract(Name = "DeleteProgramSchedule")] - public partial class DeleteProgramSchedule : IEquatable, IValidatableObject - { - /// - /// Initializes a new instance of the class. - /// - /// programScheduleId. - public DeleteProgramSchedule(int programScheduleId = default(int)) - { - this.ProgramScheduleId = programScheduleId; - } - - /// - /// Gets or Sets ProgramScheduleId - /// - [DataMember(Name = "programScheduleId", EmitDefaultValue = false)] - public int ProgramScheduleId { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("class DeleteProgramSchedule {\n"); - sb.Append(" ProgramScheduleId: ").Append(ProgramScheduleId).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as DeleteProgramSchedule); - } - - /// - /// Returns true if DeleteProgramSchedule instances are equal - /// - /// Instance of DeleteProgramSchedule to be compared - /// Boolean - public bool Equals(DeleteProgramSchedule input) - { - if (input == null) - return false; - - return - ( - this.ProgramScheduleId == input.ProgramScheduleId || - this.ProgramScheduleId.Equals(input.ProgramScheduleId) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.ProgramScheduleId.GetHashCode(); - return hashCode; - } - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/FFmpegProfileViewModel.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/FFmpegProfileViewModel.cs deleted file mode 100644 index 06d0067b8..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/FFmpegProfileViewModel.cs +++ /dev/null @@ -1,369 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// FFmpegProfileViewModel - /// - [DataContract(Name = "FFmpegProfileViewModel")] - public partial class FFmpegProfileViewModel : IEquatable, IValidatableObject - { - /// - /// Initializes a new instance of the class. - /// - /// id. - /// name. - /// threadCount. - /// transcode. - /// resolution. - /// normalizeResolution. - /// videoCodec. - /// normalizeVideoCodec. - /// videoBitrate. - /// videoBufferSize. - /// audioCodec. - /// normalizeAudioCodec. - /// audioBitrate. - /// audioBufferSize. - /// audioVolume. - /// audioChannels. - /// audioSampleRate. - /// normalizeAudio. - public FFmpegProfileViewModel(int id = default(int), string name = default(string), int threadCount = default(int), bool transcode = default(bool), ResolutionViewModel resolution = default(ResolutionViewModel), bool normalizeResolution = default(bool), string videoCodec = default(string), bool normalizeVideoCodec = default(bool), int videoBitrate = default(int), int videoBufferSize = default(int), string audioCodec = default(string), bool normalizeAudioCodec = default(bool), int audioBitrate = default(int), int audioBufferSize = default(int), int audioVolume = default(int), int audioChannels = default(int), int audioSampleRate = default(int), bool normalizeAudio = default(bool)) - { - this.Id = id; - this.Name = name; - this.ThreadCount = threadCount; - this.Transcode = transcode; - this.Resolution = resolution; - this.NormalizeResolution = normalizeResolution; - this.VideoCodec = videoCodec; - this.NormalizeVideoCodec = normalizeVideoCodec; - this.VideoBitrate = videoBitrate; - this.VideoBufferSize = videoBufferSize; - this.AudioCodec = audioCodec; - this.NormalizeAudioCodec = normalizeAudioCodec; - this.AudioBitrate = audioBitrate; - this.AudioBufferSize = audioBufferSize; - this.AudioVolume = audioVolume; - this.AudioChannels = audioChannels; - this.AudioSampleRate = audioSampleRate; - this.NormalizeAudio = normalizeAudio; - } - - /// - /// Gets or Sets Id - /// - [DataMember(Name = "id", EmitDefaultValue = false)] - public int Id { get; set; } - - /// - /// Gets or Sets Name - /// - [DataMember(Name = "name", EmitDefaultValue = true)] - public string Name { get; set; } - - /// - /// Gets or Sets ThreadCount - /// - [DataMember(Name = "threadCount", EmitDefaultValue = false)] - public int ThreadCount { get; set; } - - /// - /// Gets or Sets Transcode - /// - [DataMember(Name = "transcode", EmitDefaultValue = false)] - public bool Transcode { get; set; } - - /// - /// Gets or Sets Resolution - /// - [DataMember(Name = "resolution", EmitDefaultValue = false)] - public ResolutionViewModel Resolution { get; set; } - - /// - /// Gets or Sets NormalizeResolution - /// - [DataMember(Name = "normalizeResolution", EmitDefaultValue = false)] - public bool NormalizeResolution { get; set; } - - /// - /// Gets or Sets VideoCodec - /// - [DataMember(Name = "videoCodec", EmitDefaultValue = true)] - public string VideoCodec { get; set; } - - /// - /// Gets or Sets NormalizeVideoCodec - /// - [DataMember(Name = "normalizeVideoCodec", EmitDefaultValue = false)] - public bool NormalizeVideoCodec { get; set; } - - /// - /// Gets or Sets VideoBitrate - /// - [DataMember(Name = "videoBitrate", EmitDefaultValue = false)] - public int VideoBitrate { get; set; } - - /// - /// Gets or Sets VideoBufferSize - /// - [DataMember(Name = "videoBufferSize", EmitDefaultValue = false)] - public int VideoBufferSize { get; set; } - - /// - /// Gets or Sets AudioCodec - /// - [DataMember(Name = "audioCodec", EmitDefaultValue = true)] - public string AudioCodec { get; set; } - - /// - /// Gets or Sets NormalizeAudioCodec - /// - [DataMember(Name = "normalizeAudioCodec", EmitDefaultValue = false)] - public bool NormalizeAudioCodec { get; set; } - - /// - /// Gets or Sets AudioBitrate - /// - [DataMember(Name = "audioBitrate", EmitDefaultValue = false)] - public int AudioBitrate { get; set; } - - /// - /// Gets or Sets AudioBufferSize - /// - [DataMember(Name = "audioBufferSize", EmitDefaultValue = false)] - public int AudioBufferSize { get; set; } - - /// - /// Gets or Sets AudioVolume - /// - [DataMember(Name = "audioVolume", EmitDefaultValue = false)] - public int AudioVolume { get; set; } - - /// - /// Gets or Sets AudioChannels - /// - [DataMember(Name = "audioChannels", EmitDefaultValue = false)] - public int AudioChannels { get; set; } - - /// - /// Gets or Sets AudioSampleRate - /// - [DataMember(Name = "audioSampleRate", EmitDefaultValue = false)] - public int AudioSampleRate { get; set; } - - /// - /// Gets or Sets NormalizeAudio - /// - [DataMember(Name = "normalizeAudio", EmitDefaultValue = false)] - public bool NormalizeAudio { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("class FFmpegProfileViewModel {\n"); - sb.Append(" Id: ").Append(Id).Append("\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append(" ThreadCount: ").Append(ThreadCount).Append("\n"); - sb.Append(" Transcode: ").Append(Transcode).Append("\n"); - sb.Append(" Resolution: ").Append(Resolution).Append("\n"); - sb.Append(" NormalizeResolution: ").Append(NormalizeResolution).Append("\n"); - sb.Append(" VideoCodec: ").Append(VideoCodec).Append("\n"); - sb.Append(" NormalizeVideoCodec: ").Append(NormalizeVideoCodec).Append("\n"); - sb.Append(" VideoBitrate: ").Append(VideoBitrate).Append("\n"); - sb.Append(" VideoBufferSize: ").Append(VideoBufferSize).Append("\n"); - sb.Append(" AudioCodec: ").Append(AudioCodec).Append("\n"); - sb.Append(" NormalizeAudioCodec: ").Append(NormalizeAudioCodec).Append("\n"); - sb.Append(" AudioBitrate: ").Append(AudioBitrate).Append("\n"); - sb.Append(" AudioBufferSize: ").Append(AudioBufferSize).Append("\n"); - sb.Append(" AudioVolume: ").Append(AudioVolume).Append("\n"); - sb.Append(" AudioChannels: ").Append(AudioChannels).Append("\n"); - sb.Append(" AudioSampleRate: ").Append(AudioSampleRate).Append("\n"); - sb.Append(" NormalizeAudio: ").Append(NormalizeAudio).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as FFmpegProfileViewModel); - } - - /// - /// Returns true if FFmpegProfileViewModel instances are equal - /// - /// Instance of FFmpegProfileViewModel to be compared - /// Boolean - public bool Equals(FFmpegProfileViewModel input) - { - if (input == null) - return false; - - return - ( - this.Id == input.Id || - this.Id.Equals(input.Id) - ) && - ( - this.Name == input.Name || - (this.Name != null && - this.Name.Equals(input.Name)) - ) && - ( - this.ThreadCount == input.ThreadCount || - this.ThreadCount.Equals(input.ThreadCount) - ) && - ( - this.Transcode == input.Transcode || - this.Transcode.Equals(input.Transcode) - ) && - ( - this.Resolution == input.Resolution || - (this.Resolution != null && - this.Resolution.Equals(input.Resolution)) - ) && - ( - this.NormalizeResolution == input.NormalizeResolution || - this.NormalizeResolution.Equals(input.NormalizeResolution) - ) && - ( - this.VideoCodec == input.VideoCodec || - (this.VideoCodec != null && - this.VideoCodec.Equals(input.VideoCodec)) - ) && - ( - this.NormalizeVideoCodec == input.NormalizeVideoCodec || - this.NormalizeVideoCodec.Equals(input.NormalizeVideoCodec) - ) && - ( - this.VideoBitrate == input.VideoBitrate || - this.VideoBitrate.Equals(input.VideoBitrate) - ) && - ( - this.VideoBufferSize == input.VideoBufferSize || - this.VideoBufferSize.Equals(input.VideoBufferSize) - ) && - ( - this.AudioCodec == input.AudioCodec || - (this.AudioCodec != null && - this.AudioCodec.Equals(input.AudioCodec)) - ) && - ( - this.NormalizeAudioCodec == input.NormalizeAudioCodec || - this.NormalizeAudioCodec.Equals(input.NormalizeAudioCodec) - ) && - ( - this.AudioBitrate == input.AudioBitrate || - this.AudioBitrate.Equals(input.AudioBitrate) - ) && - ( - this.AudioBufferSize == input.AudioBufferSize || - this.AudioBufferSize.Equals(input.AudioBufferSize) - ) && - ( - this.AudioVolume == input.AudioVolume || - this.AudioVolume.Equals(input.AudioVolume) - ) && - ( - this.AudioChannels == input.AudioChannels || - this.AudioChannels.Equals(input.AudioChannels) - ) && - ( - this.AudioSampleRate == input.AudioSampleRate || - this.AudioSampleRate.Equals(input.AudioSampleRate) - ) && - ( - this.NormalizeAudio == input.NormalizeAudio || - this.NormalizeAudio.Equals(input.NormalizeAudio) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.Id.GetHashCode(); - if (this.Name != null) - hashCode = hashCode * 59 + this.Name.GetHashCode(); - hashCode = hashCode * 59 + this.ThreadCount.GetHashCode(); - hashCode = hashCode * 59 + this.Transcode.GetHashCode(); - if (this.Resolution != null) - hashCode = hashCode * 59 + this.Resolution.GetHashCode(); - hashCode = hashCode * 59 + this.NormalizeResolution.GetHashCode(); - if (this.VideoCodec != null) - hashCode = hashCode * 59 + this.VideoCodec.GetHashCode(); - hashCode = hashCode * 59 + this.NormalizeVideoCodec.GetHashCode(); - hashCode = hashCode * 59 + this.VideoBitrate.GetHashCode(); - hashCode = hashCode * 59 + this.VideoBufferSize.GetHashCode(); - if (this.AudioCodec != null) - hashCode = hashCode * 59 + this.AudioCodec.GetHashCode(); - hashCode = hashCode * 59 + this.NormalizeAudioCodec.GetHashCode(); - hashCode = hashCode * 59 + this.AudioBitrate.GetHashCode(); - hashCode = hashCode * 59 + this.AudioBufferSize.GetHashCode(); - hashCode = hashCode * 59 + this.AudioVolume.GetHashCode(); - hashCode = hashCode * 59 + this.AudioChannels.GetHashCode(); - hashCode = hashCode * 59 + this.AudioSampleRate.GetHashCode(); - hashCode = hashCode * 59 + this.NormalizeAudio.GetHashCode(); - return hashCode; - } - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/MediaCollectionViewModel.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/MediaCollectionViewModel.cs deleted file mode 100644 index ff4f9fadb..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/MediaCollectionViewModel.cs +++ /dev/null @@ -1,139 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// MediaCollectionViewModel - /// - [DataContract(Name = "MediaCollectionViewModel")] - public partial class MediaCollectionViewModel : IEquatable, IValidatableObject - { - /// - /// Initializes a new instance of the class. - /// - /// id. - /// name. - public MediaCollectionViewModel(int id = default(int), string name = default(string)) - { - this.Id = id; - this.Name = name; - } - - /// - /// Gets or Sets Id - /// - [DataMember(Name = "id", EmitDefaultValue = false)] - public int Id { get; set; } - - /// - /// Gets or Sets Name - /// - [DataMember(Name = "name", EmitDefaultValue = true)] - public string Name { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("class MediaCollectionViewModel {\n"); - sb.Append(" Id: ").Append(Id).Append("\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as MediaCollectionViewModel); - } - - /// - /// Returns true if MediaCollectionViewModel instances are equal - /// - /// Instance of MediaCollectionViewModel to be compared - /// Boolean - public bool Equals(MediaCollectionViewModel input) - { - if (input == null) - return false; - - return - ( - this.Id == input.Id || - this.Id.Equals(input.Id) - ) && - ( - this.Name == input.Name || - (this.Name != null && - this.Name.Equals(input.Name)) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.Id.GetHashCode(); - if (this.Name != null) - hashCode = hashCode * 59 + this.Name.GetHashCode(); - return hashCode; - } - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/MediaItemViewModel.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/MediaItemViewModel.cs deleted file mode 100644 index b9b4dc2eb..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/MediaItemViewModel.cs +++ /dev/null @@ -1,153 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// MediaItemViewModel - /// - [DataContract(Name = "MediaItemViewModel")] - public partial class MediaItemViewModel : IEquatable, IValidatableObject - { - /// - /// Initializes a new instance of the class. - /// - /// id. - /// mediaSourceId. - /// path. - public MediaItemViewModel(int id = default(int), int mediaSourceId = default(int), string path = default(string)) - { - this.Id = id; - this.MediaSourceId = mediaSourceId; - this.Path = path; - } - - /// - /// Gets or Sets Id - /// - [DataMember(Name = "id", EmitDefaultValue = false)] - public int Id { get; set; } - - /// - /// Gets or Sets MediaSourceId - /// - [DataMember(Name = "mediaSourceId", EmitDefaultValue = false)] - public int MediaSourceId { get; set; } - - /// - /// Gets or Sets Path - /// - [DataMember(Name = "path", EmitDefaultValue = true)] - public string Path { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("class MediaItemViewModel {\n"); - sb.Append(" Id: ").Append(Id).Append("\n"); - sb.Append(" MediaSourceId: ").Append(MediaSourceId).Append("\n"); - sb.Append(" Path: ").Append(Path).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as MediaItemViewModel); - } - - /// - /// Returns true if MediaItemViewModel instances are equal - /// - /// Instance of MediaItemViewModel to be compared - /// Boolean - public bool Equals(MediaItemViewModel input) - { - if (input == null) - return false; - - return - ( - this.Id == input.Id || - this.Id.Equals(input.Id) - ) && - ( - this.MediaSourceId == input.MediaSourceId || - this.MediaSourceId.Equals(input.MediaSourceId) - ) && - ( - this.Path == input.Path || - (this.Path != null && - this.Path.Equals(input.Path)) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.Id.GetHashCode(); - hashCode = hashCode * 59 + this.MediaSourceId.GetHashCode(); - if (this.Path != null) - hashCode = hashCode * 59 + this.Path.GetHashCode(); - return hashCode; - } - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/MediaSourceType.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/MediaSourceType.cs deleted file mode 100644 index bc935c945..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/MediaSourceType.cs +++ /dev/null @@ -1,62 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// Defines MediaSourceType - /// - - [JsonConverter(typeof(StringEnumConverter))] - - public enum MediaSourceType - { - /// - /// Enum None for value: None - /// - [EnumMember(Value = "None")] - None = 1, - - /// - /// Enum Local for value: Local - /// - [EnumMember(Value = "Local")] - Local = 2, - - /// - /// Enum Plex for value: Plex - /// - [EnumMember(Value = "Plex")] - Plex = 3, - - /// - /// Enum Jellyfin for value: Jellyfin - /// - [EnumMember(Value = "Jellyfin")] - Jellyfin = 4 - - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/MediaSourceViewModel.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/MediaSourceViewModel.cs deleted file mode 100644 index 0a70784b6..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/MediaSourceViewModel.cs +++ /dev/null @@ -1,152 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// MediaSourceViewModel - /// - [DataContract(Name = "MediaSourceViewModel")] - public partial class MediaSourceViewModel : IEquatable, IValidatableObject - { - /// - /// Gets or Sets SourceType - /// - [DataMember(Name = "sourceType", EmitDefaultValue = false)] - public MediaSourceType? SourceType { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// id. - /// name. - /// sourceType. - public MediaSourceViewModel(int id = default(int), string name = default(string), MediaSourceType? sourceType = default(MediaSourceType?)) - { - this.Id = id; - this.Name = name; - this.SourceType = sourceType; - } - - /// - /// Gets or Sets Id - /// - [DataMember(Name = "id", EmitDefaultValue = false)] - public int Id { get; set; } - - /// - /// Gets or Sets Name - /// - [DataMember(Name = "name", EmitDefaultValue = true)] - public string Name { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("class MediaSourceViewModel {\n"); - sb.Append(" Id: ").Append(Id).Append("\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append(" SourceType: ").Append(SourceType).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as MediaSourceViewModel); - } - - /// - /// Returns true if MediaSourceViewModel instances are equal - /// - /// Instance of MediaSourceViewModel to be compared - /// Boolean - public bool Equals(MediaSourceViewModel input) - { - if (input == null) - return false; - - return - ( - this.Id == input.Id || - this.Id.Equals(input.Id) - ) && - ( - this.Name == input.Name || - (this.Name != null && - this.Name.Equals(input.Name)) - ) && - ( - this.SourceType == input.SourceType || - this.SourceType.Equals(input.SourceType) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.Id.GetHashCode(); - if (this.Name != null) - hashCode = hashCode * 59 + this.Name.GetHashCode(); - hashCode = hashCode * 59 + this.SourceType.GetHashCode(); - return hashCode; - } - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/PlaybackOrder.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/PlaybackOrder.cs deleted file mode 100644 index e53bfaf86..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/PlaybackOrder.cs +++ /dev/null @@ -1,56 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// Defines PlaybackOrder - /// - - [JsonConverter(typeof(StringEnumConverter))] - - public enum PlaybackOrder - { - /// - /// Enum Chronological for value: Chronological - /// - [EnumMember(Value = "Chronological")] - Chronological = 1, - - /// - /// Enum Random for value: Random - /// - [EnumMember(Value = "Random")] - Random = 2, - - /// - /// Enum Shuffle for value: Shuffle - /// - [EnumMember(Value = "Shuffle")] - Shuffle = 3 - - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/PlayoutChannelViewModel.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/PlayoutChannelViewModel.cs deleted file mode 100644 index 05cadfa83..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/PlayoutChannelViewModel.cs +++ /dev/null @@ -1,153 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// PlayoutChannelViewModel - /// - [DataContract(Name = "PlayoutChannelViewModel")] - public partial class PlayoutChannelViewModel : IEquatable, IValidatableObject - { - /// - /// Initializes a new instance of the class. - /// - /// id. - /// number. - /// name. - public PlayoutChannelViewModel(int id = default(int), int number = default(int), string name = default(string)) - { - this.Id = id; - this.Number = number; - this.Name = name; - } - - /// - /// Gets or Sets Id - /// - [DataMember(Name = "id", EmitDefaultValue = false)] - public int Id { get; set; } - - /// - /// Gets or Sets Number - /// - [DataMember(Name = "number", EmitDefaultValue = false)] - public int Number { get; set; } - - /// - /// Gets or Sets Name - /// - [DataMember(Name = "name", EmitDefaultValue = true)] - public string Name { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("class PlayoutChannelViewModel {\n"); - sb.Append(" Id: ").Append(Id).Append("\n"); - sb.Append(" Number: ").Append(Number).Append("\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as PlayoutChannelViewModel); - } - - /// - /// Returns true if PlayoutChannelViewModel instances are equal - /// - /// Instance of PlayoutChannelViewModel to be compared - /// Boolean - public bool Equals(PlayoutChannelViewModel input) - { - if (input == null) - return false; - - return - ( - this.Id == input.Id || - this.Id.Equals(input.Id) - ) && - ( - this.Number == input.Number || - this.Number.Equals(input.Number) - ) && - ( - this.Name == input.Name || - (this.Name != null && - this.Name.Equals(input.Name)) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.Id.GetHashCode(); - hashCode = hashCode * 59 + this.Number.GetHashCode(); - if (this.Name != null) - hashCode = hashCode * 59 + this.Name.GetHashCode(); - return hashCode; - } - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/PlayoutMode.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/PlayoutMode.cs deleted file mode 100644 index 528c34df0..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/PlayoutMode.cs +++ /dev/null @@ -1,62 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// Defines PlayoutMode - /// - - [JsonConverter(typeof(StringEnumConverter))] - - public enum PlayoutMode - { - /// - /// Enum Flood for value: Flood - /// - [EnumMember(Value = "Flood")] - Flood = 1, - - /// - /// Enum One for value: One - /// - [EnumMember(Value = "One")] - One = 2, - - /// - /// Enum Multiple for value: Multiple - /// - [EnumMember(Value = "Multiple")] - Multiple = 3, - - /// - /// Enum Duration for value: Duration - /// - [EnumMember(Value = "Duration")] - Duration = 4 - - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/PlayoutProgramScheduleViewModel.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/PlayoutProgramScheduleViewModel.cs deleted file mode 100644 index 383167f45..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/PlayoutProgramScheduleViewModel.cs +++ /dev/null @@ -1,139 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// PlayoutProgramScheduleViewModel - /// - [DataContract(Name = "PlayoutProgramScheduleViewModel")] - public partial class PlayoutProgramScheduleViewModel : IEquatable, IValidatableObject - { - /// - /// Initializes a new instance of the class. - /// - /// id. - /// name. - public PlayoutProgramScheduleViewModel(int id = default(int), string name = default(string)) - { - this.Id = id; - this.Name = name; - } - - /// - /// Gets or Sets Id - /// - [DataMember(Name = "id", EmitDefaultValue = false)] - public int Id { get; set; } - - /// - /// Gets or Sets Name - /// - [DataMember(Name = "name", EmitDefaultValue = true)] - public string Name { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("class PlayoutProgramScheduleViewModel {\n"); - sb.Append(" Id: ").Append(Id).Append("\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as PlayoutProgramScheduleViewModel); - } - - /// - /// Returns true if PlayoutProgramScheduleViewModel instances are equal - /// - /// Instance of PlayoutProgramScheduleViewModel to be compared - /// Boolean - public bool Equals(PlayoutProgramScheduleViewModel input) - { - if (input == null) - return false; - - return - ( - this.Id == input.Id || - this.Id.Equals(input.Id) - ) && - ( - this.Name == input.Name || - (this.Name != null && - this.Name.Equals(input.Name)) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.Id.GetHashCode(); - if (this.Name != null) - hashCode = hashCode * 59 + this.Name.GetHashCode(); - return hashCode; - } - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/PlayoutViewModel.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/PlayoutViewModel.cs deleted file mode 100644 index d0501a0df..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/PlayoutViewModel.cs +++ /dev/null @@ -1,168 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// PlayoutViewModel - /// - [DataContract(Name = "PlayoutViewModel")] - public partial class PlayoutViewModel : IEquatable, IValidatableObject - { - /// - /// Gets or Sets ProgramSchedulePlayoutType - /// - [DataMember(Name = "programSchedulePlayoutType", EmitDefaultValue = false)] - public ProgramSchedulePlayoutType? ProgramSchedulePlayoutType { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// id. - /// channel. - /// programSchedule. - /// programSchedulePlayoutType. - public PlayoutViewModel(int id = default(int), PlayoutChannelViewModel channel = default(PlayoutChannelViewModel), PlayoutProgramScheduleViewModel programSchedule = default(PlayoutProgramScheduleViewModel), ProgramSchedulePlayoutType? programSchedulePlayoutType = default(ProgramSchedulePlayoutType?)) - { - this.Id = id; - this.Channel = channel; - this.ProgramSchedule = programSchedule; - this.ProgramSchedulePlayoutType = programSchedulePlayoutType; - } - - /// - /// Gets or Sets Id - /// - [DataMember(Name = "id", EmitDefaultValue = false)] - public int Id { get; set; } - - /// - /// Gets or Sets Channel - /// - [DataMember(Name = "channel", EmitDefaultValue = false)] - public PlayoutChannelViewModel Channel { get; set; } - - /// - /// Gets or Sets ProgramSchedule - /// - [DataMember(Name = "programSchedule", EmitDefaultValue = false)] - public PlayoutProgramScheduleViewModel ProgramSchedule { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("class PlayoutViewModel {\n"); - sb.Append(" Id: ").Append(Id).Append("\n"); - sb.Append(" Channel: ").Append(Channel).Append("\n"); - sb.Append(" ProgramSchedule: ").Append(ProgramSchedule).Append("\n"); - sb.Append(" ProgramSchedulePlayoutType: ").Append(ProgramSchedulePlayoutType).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as PlayoutViewModel); - } - - /// - /// Returns true if PlayoutViewModel instances are equal - /// - /// Instance of PlayoutViewModel to be compared - /// Boolean - public bool Equals(PlayoutViewModel input) - { - if (input == null) - return false; - - return - ( - this.Id == input.Id || - this.Id.Equals(input.Id) - ) && - ( - this.Channel == input.Channel || - (this.Channel != null && - this.Channel.Equals(input.Channel)) - ) && - ( - this.ProgramSchedule == input.ProgramSchedule || - (this.ProgramSchedule != null && - this.ProgramSchedule.Equals(input.ProgramSchedule)) - ) && - ( - this.ProgramSchedulePlayoutType == input.ProgramSchedulePlayoutType || - this.ProgramSchedulePlayoutType.Equals(input.ProgramSchedulePlayoutType) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.Id.GetHashCode(); - if (this.Channel != null) - hashCode = hashCode * 59 + this.Channel.GetHashCode(); - if (this.ProgramSchedule != null) - hashCode = hashCode * 59 + this.ProgramSchedule.GetHashCode(); - hashCode = hashCode * 59 + this.ProgramSchedulePlayoutType.GetHashCode(); - return hashCode; - } - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ProblemDetails.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ProblemDetails.cs deleted file mode 100644 index 28bddb405..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ProblemDetails.cs +++ /dev/null @@ -1,190 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// ProblemDetails - /// - [DataContract(Name = "ProblemDetails")] - public partial class ProblemDetails : Dictionary, IEquatable, IValidatableObject - { - /// - /// Initializes a new instance of the class. - /// - /// type. - /// title. - /// status. - /// detail. - /// instance. - public ProblemDetails(string type = default(string), string title = default(string), int? status = default(int?), string detail = default(string), string instance = default(string)) : base() - { - this.Type = type; - this.Title = title; - this.Status = status; - this.Detail = detail; - this.Instance = instance; - } - - /// - /// Gets or Sets Type - /// - [DataMember(Name = "type", EmitDefaultValue = true)] - public string Type { get; set; } - - /// - /// Gets or Sets Title - /// - [DataMember(Name = "title", EmitDefaultValue = true)] - public string Title { get; set; } - - /// - /// Gets or Sets Status - /// - [DataMember(Name = "status", EmitDefaultValue = true)] - public int? Status { get; set; } - - /// - /// Gets or Sets Detail - /// - [DataMember(Name = "detail", EmitDefaultValue = true)] - public string Detail { get; set; } - - /// - /// Gets or Sets Instance - /// - [DataMember(Name = "instance", EmitDefaultValue = true)] - public string Instance { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("class ProblemDetails {\n"); - sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); - sb.Append(" Type: ").Append(Type).Append("\n"); - sb.Append(" Title: ").Append(Title).Append("\n"); - sb.Append(" Status: ").Append(Status).Append("\n"); - sb.Append(" Detail: ").Append(Detail).Append("\n"); - sb.Append(" Instance: ").Append(Instance).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as ProblemDetails); - } - - /// - /// Returns true if ProblemDetails instances are equal - /// - /// Instance of ProblemDetails to be compared - /// Boolean - public bool Equals(ProblemDetails input) - { - if (input == null) - return false; - - return base.Equals(input) && - ( - this.Type == input.Type || - (this.Type != null && - this.Type.Equals(input.Type)) - ) && base.Equals(input) && - ( - this.Title == input.Title || - (this.Title != null && - this.Title.Equals(input.Title)) - ) && base.Equals(input) && - ( - this.Status == input.Status || - (this.Status != null && - this.Status.Equals(input.Status)) - ) && base.Equals(input) && - ( - this.Detail == input.Detail || - (this.Detail != null && - this.Detail.Equals(input.Detail)) - ) && base.Equals(input) && - ( - this.Instance == input.Instance || - (this.Instance != null && - this.Instance.Equals(input.Instance)) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = base.GetHashCode(); - if (this.Type != null) - hashCode = hashCode * 59 + this.Type.GetHashCode(); - if (this.Title != null) - hashCode = hashCode * 59 + this.Title.GetHashCode(); - if (this.Status != null) - hashCode = hashCode * 59 + this.Status.GetHashCode(); - if (this.Detail != null) - hashCode = hashCode * 59 + this.Detail.GetHashCode(); - if (this.Instance != null) - hashCode = hashCode * 59 + this.Instance.GetHashCode(); - return hashCode; - } - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ProgramScheduleItemViewModel.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ProgramScheduleItemViewModel.cs deleted file mode 100644 index e9d5870fe..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ProgramScheduleItemViewModel.cs +++ /dev/null @@ -1,195 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// ProgramScheduleItemViewModel - /// - [DataContract(Name = "ProgramScheduleItemViewModel")] - public partial class ProgramScheduleItemViewModel : IEquatable, IValidatableObject - { - /// - /// Gets or Sets StartType - /// - [DataMember(Name = "startType", EmitDefaultValue = false)] - public StartType? StartType { get; set; } - /// - /// Gets or Sets PlayoutMode - /// - [DataMember(Name = "playoutMode", EmitDefaultValue = false)] - public PlayoutMode? PlayoutMode { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// id. - /// index. - /// startType. - /// startTime. - /// playoutMode. - /// mediaCollection. - public ProgramScheduleItemViewModel(int id = default(int), int index = default(int), StartType? startType = default(StartType?), string startTime = default(string), PlayoutMode? playoutMode = default(PlayoutMode?), MediaCollectionViewModel mediaCollection = default(MediaCollectionViewModel)) - { - this.Id = id; - this.Index = index; - this.StartType = startType; - this.StartTime = startTime; - this.PlayoutMode = playoutMode; - this.MediaCollection = mediaCollection; - } - - /// - /// Gets or Sets Id - /// - [DataMember(Name = "id", EmitDefaultValue = false)] - public int Id { get; set; } - - /// - /// Gets or Sets Index - /// - [DataMember(Name = "index", EmitDefaultValue = false)] - public int Index { get; set; } - - /// - /// Gets or Sets StartTime - /// - [DataMember(Name = "startTime", EmitDefaultValue = true)] - public string StartTime { get; set; } - - /// - /// Gets or Sets MediaCollection - /// - [DataMember(Name = "mediaCollection", EmitDefaultValue = false)] - public MediaCollectionViewModel MediaCollection { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("class ProgramScheduleItemViewModel {\n"); - sb.Append(" Id: ").Append(Id).Append("\n"); - sb.Append(" Index: ").Append(Index).Append("\n"); - sb.Append(" StartType: ").Append(StartType).Append("\n"); - sb.Append(" StartTime: ").Append(StartTime).Append("\n"); - sb.Append(" PlayoutMode: ").Append(PlayoutMode).Append("\n"); - sb.Append(" MediaCollection: ").Append(MediaCollection).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as ProgramScheduleItemViewModel); - } - - /// - /// Returns true if ProgramScheduleItemViewModel instances are equal - /// - /// Instance of ProgramScheduleItemViewModel to be compared - /// Boolean - public bool Equals(ProgramScheduleItemViewModel input) - { - if (input == null) - return false; - - return - ( - this.Id == input.Id || - this.Id.Equals(input.Id) - ) && - ( - this.Index == input.Index || - this.Index.Equals(input.Index) - ) && - ( - this.StartType == input.StartType || - this.StartType.Equals(input.StartType) - ) && - ( - this.StartTime == input.StartTime || - (this.StartTime != null && - this.StartTime.Equals(input.StartTime)) - ) && - ( - this.PlayoutMode == input.PlayoutMode || - this.PlayoutMode.Equals(input.PlayoutMode) - ) && - ( - this.MediaCollection == input.MediaCollection || - (this.MediaCollection != null && - this.MediaCollection.Equals(input.MediaCollection)) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.Id.GetHashCode(); - hashCode = hashCode * 59 + this.Index.GetHashCode(); - hashCode = hashCode * 59 + this.StartType.GetHashCode(); - if (this.StartTime != null) - hashCode = hashCode * 59 + this.StartTime.GetHashCode(); - hashCode = hashCode * 59 + this.PlayoutMode.GetHashCode(); - if (this.MediaCollection != null) - hashCode = hashCode * 59 + this.MediaCollection.GetHashCode(); - return hashCode; - } - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ProgramSchedulePlayoutType.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ProgramSchedulePlayoutType.cs deleted file mode 100644 index 1e7bd2a4e..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ProgramSchedulePlayoutType.cs +++ /dev/null @@ -1,56 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// Defines ProgramSchedulePlayoutType - /// - - [JsonConverter(typeof(StringEnumConverter))] - - public enum ProgramSchedulePlayoutType - { - /// - /// Enum None for value: None - /// - [EnumMember(Value = "None")] - None = 1, - - /// - /// Enum Flood for value: Flood - /// - [EnumMember(Value = "Flood")] - Flood = 2, - - /// - /// Enum Daily for value: Daily - /// - [EnumMember(Value = "Daily")] - Daily = 3 - - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ProgramScheduleViewModel.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ProgramScheduleViewModel.cs deleted file mode 100644 index bb9e5159b..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ProgramScheduleViewModel.cs +++ /dev/null @@ -1,152 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// ProgramScheduleViewModel - /// - [DataContract(Name = "ProgramScheduleViewModel")] - public partial class ProgramScheduleViewModel : IEquatable, IValidatableObject - { - /// - /// Gets or Sets MediaCollectionPlaybackOrder - /// - [DataMember(Name = "mediaCollectionPlaybackOrder", EmitDefaultValue = false)] - public PlaybackOrder? MediaCollectionPlaybackOrder { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// id. - /// name. - /// mediaCollectionPlaybackOrder. - public ProgramScheduleViewModel(int id = default(int), string name = default(string), PlaybackOrder? mediaCollectionPlaybackOrder = default(PlaybackOrder?)) - { - this.Id = id; - this.Name = name; - this.MediaCollectionPlaybackOrder = mediaCollectionPlaybackOrder; - } - - /// - /// Gets or Sets Id - /// - [DataMember(Name = "id", EmitDefaultValue = false)] - public int Id { get; set; } - - /// - /// Gets or Sets Name - /// - [DataMember(Name = "name", EmitDefaultValue = true)] - public string Name { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("class ProgramScheduleViewModel {\n"); - sb.Append(" Id: ").Append(Id).Append("\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append(" MediaCollectionPlaybackOrder: ").Append(MediaCollectionPlaybackOrder).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as ProgramScheduleViewModel); - } - - /// - /// Returns true if ProgramScheduleViewModel instances are equal - /// - /// Instance of ProgramScheduleViewModel to be compared - /// Boolean - public bool Equals(ProgramScheduleViewModel input) - { - if (input == null) - return false; - - return - ( - this.Id == input.Id || - this.Id.Equals(input.Id) - ) && - ( - this.Name == input.Name || - (this.Name != null && - this.Name.Equals(input.Name)) - ) && - ( - this.MediaCollectionPlaybackOrder == input.MediaCollectionPlaybackOrder || - this.MediaCollectionPlaybackOrder.Equals(input.MediaCollectionPlaybackOrder) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.Id.GetHashCode(); - if (this.Name != null) - hashCode = hashCode * 59 + this.Name.GetHashCode(); - hashCode = hashCode * 59 + this.MediaCollectionPlaybackOrder.GetHashCode(); - return hashCode; - } - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ReplaceProgramScheduleItem.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ReplaceProgramScheduleItem.cs deleted file mode 100644 index b72e5b782..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ReplaceProgramScheduleItem.cs +++ /dev/null @@ -1,227 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// ReplaceProgramScheduleItem - /// - [DataContract(Name = "ReplaceProgramScheduleItem")] - public partial class ReplaceProgramScheduleItem : IEquatable, IValidatableObject - { - /// - /// Gets or Sets StartType - /// - [DataMember(Name = "startType", EmitDefaultValue = false)] - public StartType? StartType { get; set; } - /// - /// Gets or Sets PlayoutMode - /// - [DataMember(Name = "playoutMode", EmitDefaultValue = false)] - public PlayoutMode? PlayoutMode { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// index. - /// startType. - /// startTime. - /// playoutMode. - /// mediaCollectionId. - /// multipleCount. - /// playoutDuration. - /// offlineTail. - public ReplaceProgramScheduleItem(int index = default(int), StartType? startType = default(StartType?), string startTime = default(string), PlayoutMode? playoutMode = default(PlayoutMode?), int mediaCollectionId = default(int), int? multipleCount = default(int?), string playoutDuration = default(string), bool? offlineTail = default(bool?)) - { - this.Index = index; - this.StartType = startType; - this.StartTime = startTime; - this.PlayoutMode = playoutMode; - this.MediaCollectionId = mediaCollectionId; - this.MultipleCount = multipleCount; - this.PlayoutDuration = playoutDuration; - this.OfflineTail = offlineTail; - } - - /// - /// Gets or Sets Index - /// - [DataMember(Name = "index", EmitDefaultValue = false)] - public int Index { get; set; } - - /// - /// Gets or Sets StartTime - /// - [DataMember(Name = "startTime", EmitDefaultValue = true)] - public string StartTime { get; set; } - - /// - /// Gets or Sets MediaCollectionId - /// - [DataMember(Name = "mediaCollectionId", EmitDefaultValue = false)] - public int MediaCollectionId { get; set; } - - /// - /// Gets or Sets MultipleCount - /// - [DataMember(Name = "multipleCount", EmitDefaultValue = true)] - public int? MultipleCount { get; set; } - - /// - /// Gets or Sets PlayoutDuration - /// - [DataMember(Name = "playoutDuration", EmitDefaultValue = true)] - public string PlayoutDuration { get; set; } - - /// - /// Gets or Sets OfflineTail - /// - [DataMember(Name = "offlineTail", EmitDefaultValue = true)] - public bool? OfflineTail { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("class ReplaceProgramScheduleItem {\n"); - sb.Append(" Index: ").Append(Index).Append("\n"); - sb.Append(" StartType: ").Append(StartType).Append("\n"); - sb.Append(" StartTime: ").Append(StartTime).Append("\n"); - sb.Append(" PlayoutMode: ").Append(PlayoutMode).Append("\n"); - sb.Append(" MediaCollectionId: ").Append(MediaCollectionId).Append("\n"); - sb.Append(" MultipleCount: ").Append(MultipleCount).Append("\n"); - sb.Append(" PlayoutDuration: ").Append(PlayoutDuration).Append("\n"); - sb.Append(" OfflineTail: ").Append(OfflineTail).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as ReplaceProgramScheduleItem); - } - - /// - /// Returns true if ReplaceProgramScheduleItem instances are equal - /// - /// Instance of ReplaceProgramScheduleItem to be compared - /// Boolean - public bool Equals(ReplaceProgramScheduleItem input) - { - if (input == null) - return false; - - return - ( - this.Index == input.Index || - this.Index.Equals(input.Index) - ) && - ( - this.StartType == input.StartType || - this.StartType.Equals(input.StartType) - ) && - ( - this.StartTime == input.StartTime || - (this.StartTime != null && - this.StartTime.Equals(input.StartTime)) - ) && - ( - this.PlayoutMode == input.PlayoutMode || - this.PlayoutMode.Equals(input.PlayoutMode) - ) && - ( - this.MediaCollectionId == input.MediaCollectionId || - this.MediaCollectionId.Equals(input.MediaCollectionId) - ) && - ( - this.MultipleCount == input.MultipleCount || - (this.MultipleCount != null && - this.MultipleCount.Equals(input.MultipleCount)) - ) && - ( - this.PlayoutDuration == input.PlayoutDuration || - (this.PlayoutDuration != null && - this.PlayoutDuration.Equals(input.PlayoutDuration)) - ) && - ( - this.OfflineTail == input.OfflineTail || - (this.OfflineTail != null && - this.OfflineTail.Equals(input.OfflineTail)) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.Index.GetHashCode(); - hashCode = hashCode * 59 + this.StartType.GetHashCode(); - if (this.StartTime != null) - hashCode = hashCode * 59 + this.StartTime.GetHashCode(); - hashCode = hashCode * 59 + this.PlayoutMode.GetHashCode(); - hashCode = hashCode * 59 + this.MediaCollectionId.GetHashCode(); - if (this.MultipleCount != null) - hashCode = hashCode * 59 + this.MultipleCount.GetHashCode(); - if (this.PlayoutDuration != null) - hashCode = hashCode * 59 + this.PlayoutDuration.GetHashCode(); - if (this.OfflineTail != null) - hashCode = hashCode * 59 + this.OfflineTail.GetHashCode(); - return hashCode; - } - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ResolutionViewModel.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ResolutionViewModel.cs deleted file mode 100644 index 252cf9e72..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/ResolutionViewModel.cs +++ /dev/null @@ -1,167 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// ResolutionViewModel - /// - [DataContract(Name = "ResolutionViewModel")] - public partial class ResolutionViewModel : IEquatable, IValidatableObject - { - /// - /// Initializes a new instance of the class. - /// - /// id. - /// name. - /// width. - /// height. - public ResolutionViewModel(int id = default(int), string name = default(string), int width = default(int), int height = default(int)) - { - this.Id = id; - this.Name = name; - this.Width = width; - this.Height = height; - } - - /// - /// Gets or Sets Id - /// - [DataMember(Name = "id", EmitDefaultValue = false)] - public int Id { get; set; } - - /// - /// Gets or Sets Name - /// - [DataMember(Name = "name", EmitDefaultValue = true)] - public string Name { get; set; } - - /// - /// Gets or Sets Width - /// - [DataMember(Name = "width", EmitDefaultValue = false)] - public int Width { get; set; } - - /// - /// Gets or Sets Height - /// - [DataMember(Name = "height", EmitDefaultValue = false)] - public int Height { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("class ResolutionViewModel {\n"); - sb.Append(" Id: ").Append(Id).Append("\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append(" Width: ").Append(Width).Append("\n"); - sb.Append(" Height: ").Append(Height).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as ResolutionViewModel); - } - - /// - /// Returns true if ResolutionViewModel instances are equal - /// - /// Instance of ResolutionViewModel to be compared - /// Boolean - public bool Equals(ResolutionViewModel input) - { - if (input == null) - return false; - - return - ( - this.Id == input.Id || - this.Id.Equals(input.Id) - ) && - ( - this.Name == input.Name || - (this.Name != null && - this.Name.Equals(input.Name)) - ) && - ( - this.Width == input.Width || - this.Width.Equals(input.Width) - ) && - ( - this.Height == input.Height || - this.Height.Equals(input.Height) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.Id.GetHashCode(); - if (this.Name != null) - hashCode = hashCode * 59 + this.Name.GetHashCode(); - hashCode = hashCode * 59 + this.Width.GetHashCode(); - hashCode = hashCode * 59 + this.Height.GetHashCode(); - return hashCode; - } - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/StartType.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/StartType.cs deleted file mode 100644 index d37c7996d..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/StartType.cs +++ /dev/null @@ -1,50 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// Defines StartType - /// - - [JsonConverter(typeof(StringEnumConverter))] - - public enum StartType - { - /// - /// Enum Dynamic for value: Dynamic - /// - [EnumMember(Value = "Dynamic")] - Dynamic = 1, - - /// - /// Enum Fixed for value: Fixed - /// - [EnumMember(Value = "Fixed")] - Fixed = 2 - - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/StreamingMode.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/StreamingMode.cs deleted file mode 100644 index 20d44a1ee..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/StreamingMode.cs +++ /dev/null @@ -1,50 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// Defines StreamingMode - /// - - [JsonConverter(typeof(StringEnumConverter))] - - public enum StreamingMode - { - /// - /// Enum TransportStream for value: TransportStream - /// - [EnumMember(Value = "TransportStream")] - TransportStream = 1, - - /// - /// Enum HttpLiveStreaming for value: HttpLiveStreaming - /// - [EnumMember(Value = "HttpLiveStreaming")] - HttpLiveStreaming = 2 - - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/UpdateChannel.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/UpdateChannel.cs deleted file mode 100644 index e35b5ad5c..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/UpdateChannel.cs +++ /dev/null @@ -1,196 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// UpdateChannel - /// - [DataContract(Name = "UpdateChannel")] - public partial class UpdateChannel : IEquatable, IValidatableObject - { - /// - /// Gets or Sets StreamingMode - /// - [DataMember(Name = "streamingMode", EmitDefaultValue = false)] - public StreamingMode? StreamingMode { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// channelId. - /// name. - /// number. - /// ffmpegProfileId. - /// logo. - /// streamingMode. - public UpdateChannel(int channelId = default(int), string name = default(string), int number = default(int), int ffmpegProfileId = default(int), string logo = default(string), StreamingMode? streamingMode = default(StreamingMode?)) - { - this.ChannelId = channelId; - this.Name = name; - this.Number = number; - this.FfmpegProfileId = ffmpegProfileId; - this.Logo = logo; - this.StreamingMode = streamingMode; - } - - /// - /// Gets or Sets ChannelId - /// - [DataMember(Name = "channelId", EmitDefaultValue = false)] - public int ChannelId { get; set; } - - /// - /// Gets or Sets Name - /// - [DataMember(Name = "name", EmitDefaultValue = true)] - public string Name { get; set; } - - /// - /// Gets or Sets Number - /// - [DataMember(Name = "number", EmitDefaultValue = false)] - public int Number { get; set; } - - /// - /// Gets or Sets FfmpegProfileId - /// - [DataMember(Name = "ffmpegProfileId", EmitDefaultValue = false)] - public int FfmpegProfileId { get; set; } - - /// - /// Gets or Sets Logo - /// - [DataMember(Name = "logo", EmitDefaultValue = true)] - public string Logo { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("class UpdateChannel {\n"); - sb.Append(" ChannelId: ").Append(ChannelId).Append("\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append(" Number: ").Append(Number).Append("\n"); - sb.Append(" FfmpegProfileId: ").Append(FfmpegProfileId).Append("\n"); - sb.Append(" Logo: ").Append(Logo).Append("\n"); - sb.Append(" StreamingMode: ").Append(StreamingMode).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as UpdateChannel); - } - - /// - /// Returns true if UpdateChannel instances are equal - /// - /// Instance of UpdateChannel to be compared - /// Boolean - public bool Equals(UpdateChannel input) - { - if (input == null) - return false; - - return - ( - this.ChannelId == input.ChannelId || - this.ChannelId.Equals(input.ChannelId) - ) && - ( - this.Name == input.Name || - (this.Name != null && - this.Name.Equals(input.Name)) - ) && - ( - this.Number == input.Number || - this.Number.Equals(input.Number) - ) && - ( - this.FfmpegProfileId == input.FfmpegProfileId || - this.FfmpegProfileId.Equals(input.FfmpegProfileId) - ) && - ( - this.Logo == input.Logo || - (this.Logo != null && - this.Logo.Equals(input.Logo)) - ) && - ( - this.StreamingMode == input.StreamingMode || - this.StreamingMode.Equals(input.StreamingMode) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.ChannelId.GetHashCode(); - if (this.Name != null) - hashCode = hashCode * 59 + this.Name.GetHashCode(); - hashCode = hashCode * 59 + this.Number.GetHashCode(); - hashCode = hashCode * 59 + this.FfmpegProfileId.GetHashCode(); - if (this.Logo != null) - hashCode = hashCode * 59 + this.Logo.GetHashCode(); - hashCode = hashCode * 59 + this.StreamingMode.GetHashCode(); - return hashCode; - } - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/UpdateFFmpegProfile.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/UpdateFFmpegProfile.cs deleted file mode 100644 index e6fb4c44d..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/UpdateFFmpegProfile.cs +++ /dev/null @@ -1,367 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// UpdateFFmpegProfile - /// - [DataContract(Name = "UpdateFFmpegProfile")] - public partial class UpdateFFmpegProfile : IEquatable, IValidatableObject - { - /// - /// Initializes a new instance of the class. - /// - /// ffmpegProfileId. - /// name. - /// threadCount. - /// transcode. - /// resolutionId. - /// normalizeResolution. - /// videoCodec. - /// normalizeVideoCodec. - /// videoBitrate. - /// videoBufferSize. - /// audioCodec. - /// normalizeAudioCodec. - /// audioBitrate. - /// audioBufferSize. - /// audioVolume. - /// audioChannels. - /// audioSampleRate. - /// normalizeAudio. - public UpdateFFmpegProfile(int ffmpegProfileId = default(int), string name = default(string), int threadCount = default(int), bool transcode = default(bool), int resolutionId = default(int), bool normalizeResolution = default(bool), string videoCodec = default(string), bool normalizeVideoCodec = default(bool), int videoBitrate = default(int), int videoBufferSize = default(int), string audioCodec = default(string), bool normalizeAudioCodec = default(bool), int audioBitrate = default(int), int audioBufferSize = default(int), int audioVolume = default(int), int audioChannels = default(int), int audioSampleRate = default(int), bool normalizeAudio = default(bool)) - { - this.FfmpegProfileId = ffmpegProfileId; - this.Name = name; - this.ThreadCount = threadCount; - this.Transcode = transcode; - this.ResolutionId = resolutionId; - this.NormalizeResolution = normalizeResolution; - this.VideoCodec = videoCodec; - this.NormalizeVideoCodec = normalizeVideoCodec; - this.VideoBitrate = videoBitrate; - this.VideoBufferSize = videoBufferSize; - this.AudioCodec = audioCodec; - this.NormalizeAudioCodec = normalizeAudioCodec; - this.AudioBitrate = audioBitrate; - this.AudioBufferSize = audioBufferSize; - this.AudioVolume = audioVolume; - this.AudioChannels = audioChannels; - this.AudioSampleRate = audioSampleRate; - this.NormalizeAudio = normalizeAudio; - } - - /// - /// Gets or Sets FfmpegProfileId - /// - [DataMember(Name = "ffmpegProfileId", EmitDefaultValue = false)] - public int FfmpegProfileId { get; set; } - - /// - /// Gets or Sets Name - /// - [DataMember(Name = "name", EmitDefaultValue = true)] - public string Name { get; set; } - - /// - /// Gets or Sets ThreadCount - /// - [DataMember(Name = "threadCount", EmitDefaultValue = false)] - public int ThreadCount { get; set; } - - /// - /// Gets or Sets Transcode - /// - [DataMember(Name = "transcode", EmitDefaultValue = false)] - public bool Transcode { get; set; } - - /// - /// Gets or Sets ResolutionId - /// - [DataMember(Name = "resolutionId", EmitDefaultValue = false)] - public int ResolutionId { get; set; } - - /// - /// Gets or Sets NormalizeResolution - /// - [DataMember(Name = "normalizeResolution", EmitDefaultValue = false)] - public bool NormalizeResolution { get; set; } - - /// - /// Gets or Sets VideoCodec - /// - [DataMember(Name = "videoCodec", EmitDefaultValue = true)] - public string VideoCodec { get; set; } - - /// - /// Gets or Sets NormalizeVideoCodec - /// - [DataMember(Name = "normalizeVideoCodec", EmitDefaultValue = false)] - public bool NormalizeVideoCodec { get; set; } - - /// - /// Gets or Sets VideoBitrate - /// - [DataMember(Name = "videoBitrate", EmitDefaultValue = false)] - public int VideoBitrate { get; set; } - - /// - /// Gets or Sets VideoBufferSize - /// - [DataMember(Name = "videoBufferSize", EmitDefaultValue = false)] - public int VideoBufferSize { get; set; } - - /// - /// Gets or Sets AudioCodec - /// - [DataMember(Name = "audioCodec", EmitDefaultValue = true)] - public string AudioCodec { get; set; } - - /// - /// Gets or Sets NormalizeAudioCodec - /// - [DataMember(Name = "normalizeAudioCodec", EmitDefaultValue = false)] - public bool NormalizeAudioCodec { get; set; } - - /// - /// Gets or Sets AudioBitrate - /// - [DataMember(Name = "audioBitrate", EmitDefaultValue = false)] - public int AudioBitrate { get; set; } - - /// - /// Gets or Sets AudioBufferSize - /// - [DataMember(Name = "audioBufferSize", EmitDefaultValue = false)] - public int AudioBufferSize { get; set; } - - /// - /// Gets or Sets AudioVolume - /// - [DataMember(Name = "audioVolume", EmitDefaultValue = false)] - public int AudioVolume { get; set; } - - /// - /// Gets or Sets AudioChannels - /// - [DataMember(Name = "audioChannels", EmitDefaultValue = false)] - public int AudioChannels { get; set; } - - /// - /// Gets or Sets AudioSampleRate - /// - [DataMember(Name = "audioSampleRate", EmitDefaultValue = false)] - public int AudioSampleRate { get; set; } - - /// - /// Gets or Sets NormalizeAudio - /// - [DataMember(Name = "normalizeAudio", EmitDefaultValue = false)] - public bool NormalizeAudio { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("class UpdateFFmpegProfile {\n"); - sb.Append(" FfmpegProfileId: ").Append(FfmpegProfileId).Append("\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append(" ThreadCount: ").Append(ThreadCount).Append("\n"); - sb.Append(" Transcode: ").Append(Transcode).Append("\n"); - sb.Append(" ResolutionId: ").Append(ResolutionId).Append("\n"); - sb.Append(" NormalizeResolution: ").Append(NormalizeResolution).Append("\n"); - sb.Append(" VideoCodec: ").Append(VideoCodec).Append("\n"); - sb.Append(" NormalizeVideoCodec: ").Append(NormalizeVideoCodec).Append("\n"); - sb.Append(" VideoBitrate: ").Append(VideoBitrate).Append("\n"); - sb.Append(" VideoBufferSize: ").Append(VideoBufferSize).Append("\n"); - sb.Append(" AudioCodec: ").Append(AudioCodec).Append("\n"); - sb.Append(" NormalizeAudioCodec: ").Append(NormalizeAudioCodec).Append("\n"); - sb.Append(" AudioBitrate: ").Append(AudioBitrate).Append("\n"); - sb.Append(" AudioBufferSize: ").Append(AudioBufferSize).Append("\n"); - sb.Append(" AudioVolume: ").Append(AudioVolume).Append("\n"); - sb.Append(" AudioChannels: ").Append(AudioChannels).Append("\n"); - sb.Append(" AudioSampleRate: ").Append(AudioSampleRate).Append("\n"); - sb.Append(" NormalizeAudio: ").Append(NormalizeAudio).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as UpdateFFmpegProfile); - } - - /// - /// Returns true if UpdateFFmpegProfile instances are equal - /// - /// Instance of UpdateFFmpegProfile to be compared - /// Boolean - public bool Equals(UpdateFFmpegProfile input) - { - if (input == null) - return false; - - return - ( - this.FfmpegProfileId == input.FfmpegProfileId || - this.FfmpegProfileId.Equals(input.FfmpegProfileId) - ) && - ( - this.Name == input.Name || - (this.Name != null && - this.Name.Equals(input.Name)) - ) && - ( - this.ThreadCount == input.ThreadCount || - this.ThreadCount.Equals(input.ThreadCount) - ) && - ( - this.Transcode == input.Transcode || - this.Transcode.Equals(input.Transcode) - ) && - ( - this.ResolutionId == input.ResolutionId || - this.ResolutionId.Equals(input.ResolutionId) - ) && - ( - this.NormalizeResolution == input.NormalizeResolution || - this.NormalizeResolution.Equals(input.NormalizeResolution) - ) && - ( - this.VideoCodec == input.VideoCodec || - (this.VideoCodec != null && - this.VideoCodec.Equals(input.VideoCodec)) - ) && - ( - this.NormalizeVideoCodec == input.NormalizeVideoCodec || - this.NormalizeVideoCodec.Equals(input.NormalizeVideoCodec) - ) && - ( - this.VideoBitrate == input.VideoBitrate || - this.VideoBitrate.Equals(input.VideoBitrate) - ) && - ( - this.VideoBufferSize == input.VideoBufferSize || - this.VideoBufferSize.Equals(input.VideoBufferSize) - ) && - ( - this.AudioCodec == input.AudioCodec || - (this.AudioCodec != null && - this.AudioCodec.Equals(input.AudioCodec)) - ) && - ( - this.NormalizeAudioCodec == input.NormalizeAudioCodec || - this.NormalizeAudioCodec.Equals(input.NormalizeAudioCodec) - ) && - ( - this.AudioBitrate == input.AudioBitrate || - this.AudioBitrate.Equals(input.AudioBitrate) - ) && - ( - this.AudioBufferSize == input.AudioBufferSize || - this.AudioBufferSize.Equals(input.AudioBufferSize) - ) && - ( - this.AudioVolume == input.AudioVolume || - this.AudioVolume.Equals(input.AudioVolume) - ) && - ( - this.AudioChannels == input.AudioChannels || - this.AudioChannels.Equals(input.AudioChannels) - ) && - ( - this.AudioSampleRate == input.AudioSampleRate || - this.AudioSampleRate.Equals(input.AudioSampleRate) - ) && - ( - this.NormalizeAudio == input.NormalizeAudio || - this.NormalizeAudio.Equals(input.NormalizeAudio) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.FfmpegProfileId.GetHashCode(); - if (this.Name != null) - hashCode = hashCode * 59 + this.Name.GetHashCode(); - hashCode = hashCode * 59 + this.ThreadCount.GetHashCode(); - hashCode = hashCode * 59 + this.Transcode.GetHashCode(); - hashCode = hashCode * 59 + this.ResolutionId.GetHashCode(); - hashCode = hashCode * 59 + this.NormalizeResolution.GetHashCode(); - if (this.VideoCodec != null) - hashCode = hashCode * 59 + this.VideoCodec.GetHashCode(); - hashCode = hashCode * 59 + this.NormalizeVideoCodec.GetHashCode(); - hashCode = hashCode * 59 + this.VideoBitrate.GetHashCode(); - hashCode = hashCode * 59 + this.VideoBufferSize.GetHashCode(); - if (this.AudioCodec != null) - hashCode = hashCode * 59 + this.AudioCodec.GetHashCode(); - hashCode = hashCode * 59 + this.NormalizeAudioCodec.GetHashCode(); - hashCode = hashCode * 59 + this.AudioBitrate.GetHashCode(); - hashCode = hashCode * 59 + this.AudioBufferSize.GetHashCode(); - hashCode = hashCode * 59 + this.AudioVolume.GetHashCode(); - hashCode = hashCode * 59 + this.AudioChannels.GetHashCode(); - hashCode = hashCode * 59 + this.AudioSampleRate.GetHashCode(); - hashCode = hashCode * 59 + this.NormalizeAudio.GetHashCode(); - return hashCode; - } - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/UpdatePlayout.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/UpdatePlayout.cs deleted file mode 100644 index 9e3ae565b..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/UpdatePlayout.cs +++ /dev/null @@ -1,164 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// UpdatePlayout - /// - [DataContract(Name = "UpdatePlayout")] - public partial class UpdatePlayout : IEquatable, IValidatableObject - { - /// - /// Gets or Sets ProgramSchedulePlayoutType - /// - [DataMember(Name = "programSchedulePlayoutType", EmitDefaultValue = false)] - public ProgramSchedulePlayoutType? ProgramSchedulePlayoutType { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// playoutId. - /// channelId. - /// programScheduleId. - /// programSchedulePlayoutType. - public UpdatePlayout(int playoutId = default(int), int channelId = default(int), int programScheduleId = default(int), ProgramSchedulePlayoutType? programSchedulePlayoutType = default(ProgramSchedulePlayoutType?)) - { - this.PlayoutId = playoutId; - this.ChannelId = channelId; - this.ProgramScheduleId = programScheduleId; - this.ProgramSchedulePlayoutType = programSchedulePlayoutType; - } - - /// - /// Gets or Sets PlayoutId - /// - [DataMember(Name = "playoutId", EmitDefaultValue = false)] - public int PlayoutId { get; set; } - - /// - /// Gets or Sets ChannelId - /// - [DataMember(Name = "channelId", EmitDefaultValue = false)] - public int ChannelId { get; set; } - - /// - /// Gets or Sets ProgramScheduleId - /// - [DataMember(Name = "programScheduleId", EmitDefaultValue = false)] - public int ProgramScheduleId { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("class UpdatePlayout {\n"); - sb.Append(" PlayoutId: ").Append(PlayoutId).Append("\n"); - sb.Append(" ChannelId: ").Append(ChannelId).Append("\n"); - sb.Append(" ProgramScheduleId: ").Append(ProgramScheduleId).Append("\n"); - sb.Append(" ProgramSchedulePlayoutType: ").Append(ProgramSchedulePlayoutType).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as UpdatePlayout); - } - - /// - /// Returns true if UpdatePlayout instances are equal - /// - /// Instance of UpdatePlayout to be compared - /// Boolean - public bool Equals(UpdatePlayout input) - { - if (input == null) - return false; - - return - ( - this.PlayoutId == input.PlayoutId || - this.PlayoutId.Equals(input.PlayoutId) - ) && - ( - this.ChannelId == input.ChannelId || - this.ChannelId.Equals(input.ChannelId) - ) && - ( - this.ProgramScheduleId == input.ProgramScheduleId || - this.ProgramScheduleId.Equals(input.ProgramScheduleId) - ) && - ( - this.ProgramSchedulePlayoutType == input.ProgramSchedulePlayoutType || - this.ProgramSchedulePlayoutType.Equals(input.ProgramSchedulePlayoutType) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.PlayoutId.GetHashCode(); - hashCode = hashCode * 59 + this.ChannelId.GetHashCode(); - hashCode = hashCode * 59 + this.ProgramScheduleId.GetHashCode(); - hashCode = hashCode * 59 + this.ProgramSchedulePlayoutType.GetHashCode(); - return hashCode; - } - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } - } - -} diff --git a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/UpdateProgramSchedule.cs b/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/UpdateProgramSchedule.cs deleted file mode 100644 index 2fcb37742..000000000 --- a/generated/ErsatzTV.Api.Sdk/src/ErsatzTV.Api.Sdk/Model/UpdateProgramSchedule.cs +++ /dev/null @@ -1,152 +0,0 @@ -/* - * ErsatzTV API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: v1 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = ErsatzTV.Api.Sdk.Client.OpenAPIDateConverter; - -namespace ErsatzTV.Api.Sdk.Model -{ - /// - /// UpdateProgramSchedule - /// - [DataContract(Name = "UpdateProgramSchedule")] - public partial class UpdateProgramSchedule : IEquatable, IValidatableObject - { - /// - /// Gets or Sets MediaCollectionPlaybackOrder - /// - [DataMember(Name = "mediaCollectionPlaybackOrder", EmitDefaultValue = false)] - public PlaybackOrder? MediaCollectionPlaybackOrder { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// programScheduleId. - /// name. - /// mediaCollectionPlaybackOrder. - public UpdateProgramSchedule(int programScheduleId = default(int), string name = default(string), PlaybackOrder? mediaCollectionPlaybackOrder = default(PlaybackOrder?)) - { - this.ProgramScheduleId = programScheduleId; - this.Name = name; - this.MediaCollectionPlaybackOrder = mediaCollectionPlaybackOrder; - } - - /// - /// Gets or Sets ProgramScheduleId - /// - [DataMember(Name = "programScheduleId", EmitDefaultValue = false)] - public int ProgramScheduleId { get; set; } - - /// - /// Gets or Sets Name - /// - [DataMember(Name = "name", EmitDefaultValue = true)] - public string Name { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("class UpdateProgramSchedule {\n"); - sb.Append(" ProgramScheduleId: ").Append(ProgramScheduleId).Append("\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append(" MediaCollectionPlaybackOrder: ").Append(MediaCollectionPlaybackOrder).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as UpdateProgramSchedule); - } - - /// - /// Returns true if UpdateProgramSchedule instances are equal - /// - /// Instance of UpdateProgramSchedule to be compared - /// Boolean - public bool Equals(UpdateProgramSchedule input) - { - if (input == null) - return false; - - return - ( - this.ProgramScheduleId == input.ProgramScheduleId || - this.ProgramScheduleId.Equals(input.ProgramScheduleId) - ) && - ( - this.Name == input.Name || - (this.Name != null && - this.Name.Equals(input.Name)) - ) && - ( - this.MediaCollectionPlaybackOrder == input.MediaCollectionPlaybackOrder || - this.MediaCollectionPlaybackOrder.Equals(input.MediaCollectionPlaybackOrder) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = hashCode * 59 + this.ProgramScheduleId.GetHashCode(); - if (this.Name != null) - hashCode = hashCode * 59 + this.Name.GetHashCode(); - hashCode = hashCode * 59 + this.MediaCollectionPlaybackOrder.GetHashCode(); - return hashCode; - } - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } - } - -} diff --git a/scripts/generate-api-sdk/.openapi-generator-ignore b/scripts/generate-api-sdk/.openapi-generator-ignore deleted file mode 100644 index b86669310..000000000 --- a/scripts/generate-api-sdk/.openapi-generator-ignore +++ /dev/null @@ -1,5 +0,0 @@ -docs/** -git_push.sh -ErsatzTV.Api.Sdk.sln -.gitignore -README.md diff --git a/scripts/generate-api-sdk/generate-api-sdk.sh b/scripts/generate-api-sdk/generate-api-sdk.sh deleted file mode 100755 index e309a407b..000000000 --- a/scripts/generate-api-sdk/generate-api-sdk.sh +++ /dev/null @@ -1,24 +0,0 @@ -#! /usr/bin/env bash -set -e - -TARGET_FOLDER="../../generated/ErsatzTV.Api.Sdk" - -rm -f swagger.json - -dotnet tool restore - -dotnet build ../../ErsatzTV/ErsatzTV.csproj -dotnet swagger tofile --output swagger.json ../../ErsatzTV/bin/Debug/net5.0/ErsatzTV.dll v1 - -rm -rf "$TARGET_FOLDER" -mkdir "$TARGET_FOLDER" -cp .openapi-generator-ignore "$TARGET_FOLDER/" - -openapi-generator-cli generate -i swagger.json \ - -g csharp-netcore \ - -o $TARGET_FOLDER \ - --additional-properties packageName=ErsatzTV.Api.Sdk \ - --additional-properties=targetFramework=netcoreapp3.1 - -rm -f "$TARGET_FOLDER/appveyor.yml" -rm -rf "$TARGET_FOLDER/src/ErsatzTV.Api.Sdk.Test" diff --git a/scripts/generate-api-sdk/openapitools.json b/scripts/generate-api-sdk/openapitools.json deleted file mode 100644 index bfebfaade..000000000 --- a/scripts/generate-api-sdk/openapitools.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json", - "spaces": 2, - "generator-cli": { - "version": "5.0.0" - } -}