Browse Source

code cleanup (#743)

* update tools

* run code cleanup

* update dependencies
pull/744/head
Jason Dove 4 years ago committed by GitHub
parent
commit
c02b83d0d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .config/dotnet-tools.json
  2. 6
      ErsatzTV.Application/Channels/Commands/CreateChannelHandler.cs
  3. 2
      ErsatzTV.Application/Channels/Commands/UpdateChannelHandler.cs
  4. 2
      ErsatzTV.Application/Configuration/Commands/SaveConfigElementByKey.cs
  5. 2
      ErsatzTV.Application/Configuration/Commands/SaveConfigElementByKeyHandler.cs
  6. 2
      ErsatzTV.Application/Configuration/Commands/UpdateLibraryRefreshInterval.cs
  7. 7
      ErsatzTV.Application/Configuration/Commands/UpdateLibraryRefreshIntervalHandler.cs
  8. 2
      ErsatzTV.Application/Configuration/Commands/UpdatePlayoutDaysToBuild.cs
  9. 2
      ErsatzTV.Application/Emby/Commands/DisconnectEmby.cs
  10. 2
      ErsatzTV.Application/Emby/Commands/DisconnectEmbyHandler.cs
  11. 2
      ErsatzTV.Application/Emby/Commands/SaveEmbySecrets.cs
  12. 2
      ErsatzTV.Application/Emby/Commands/SaveEmbySecretsHandler.cs
  13. 2
      ErsatzTV.Application/Emby/Commands/SynchronizeEmbyLibraries.cs
  14. 2
      ErsatzTV.Application/Emby/Commands/SynchronizeEmbyLibrariesHandler.cs
  15. 2
      ErsatzTV.Application/Emby/Commands/UpdateEmbyLibraryPreferences.cs
  16. 2
      ErsatzTV.Application/Emby/Commands/UpdateEmbyLibraryPreferencesHandler.cs
  17. 2
      ErsatzTV.Application/Emby/Commands/UpdateEmbyPathReplacements.cs
  18. 2
      ErsatzTV.Application/Emby/Commands/UpdateEmbyPathReplacementsHandler.cs
  19. 2
      ErsatzTV.Application/ErsatzTV.Application.csproj
  20. 6
      ErsatzTV.Application/FFmpegProfiles/Commands/CreateFFmpegProfileHandler.cs
  21. 2
      ErsatzTV.Application/FFmpegProfiles/Commands/DeleteFFmpegProfile.cs
  22. 8
      ErsatzTV.Application/FFmpegProfiles/Commands/DeleteFFmpegProfileHandler.cs
  23. 2
      ErsatzTV.Application/FFmpegProfiles/Commands/UpdateFFmpegProfileHandler.cs
  24. 2
      ErsatzTV.Application/FFmpegProfiles/Commands/UpdateFFmpegSettings.cs
  25. 2
      ErsatzTV.Application/FFmpegProfiles/Queries/GetFFmpegSettingsHandler.cs
  26. 2
      ErsatzTV.Application/Filler/Commands/DeleteFillerPreset.cs
  27. 4
      ErsatzTV.Application/Filler/Commands/UpdateFillerPresetHandler.cs
  28. 4
      ErsatzTV.Application/Filler/Queries/GetPagedFillerPresetsHandler.cs
  29. 2
      ErsatzTV.Application/HDHR/Commands/UpdateHDHRTunerCount.cs
  30. 2
      ErsatzTV.Application/HDHR/Commands/UpdateHDHRTunerCountHandler.cs
  31. 4
      ErsatzTV.Application/Images/Queries/GetCachedImagePathHandler.cs
  32. 2
      ErsatzTV.Application/Jellyfin/Commands/DisconnectJellyfin.cs
  33. 2
      ErsatzTV.Application/Jellyfin/Commands/DisconnectJellyfinHandler.cs
  34. 2
      ErsatzTV.Application/Jellyfin/Commands/SaveJellyfinSecrets.cs
  35. 2
      ErsatzTV.Application/Jellyfin/Commands/SaveJellyfinSecretsHandler.cs
  36. 2
      ErsatzTV.Application/Jellyfin/Commands/SynchronizeJellyfinAdminUserId.cs
  37. 2
      ErsatzTV.Application/Jellyfin/Commands/SynchronizeJellyfinAdminUserIdHandler.cs
  38. 2
      ErsatzTV.Application/Jellyfin/Commands/SynchronizeJellyfinLibraries.cs
  39. 2
      ErsatzTV.Application/Jellyfin/Commands/SynchronizeJellyfinLibrariesHandler.cs
  40. 2
      ErsatzTV.Application/Jellyfin/Commands/UpdateJellyfinLibraryPreferences.cs
  41. 2
      ErsatzTV.Application/Jellyfin/Commands/UpdateJellyfinLibraryPreferencesHandler.cs
  42. 2
      ErsatzTV.Application/Jellyfin/Commands/UpdateJellyfinPathReplacements.cs
  43. 2
      ErsatzTV.Application/Jellyfin/Commands/UpdateJellyfinPathReplacementsHandler.cs
  44. 4
      ErsatzTV.Application/Libraries/Commands/CreateLocalLibraryHandler.cs
  45. 2
      ErsatzTV.Application/Libraries/Commands/DeleteLocalLibraryHandler.cs
  46. 6
      ErsatzTV.Application/Libraries/Commands/MoveLocalLibraryPathHandler.cs
  47. 14
      ErsatzTV.Application/Libraries/Commands/UpdateLocalLibraryHandler.cs
  48. 4
      ErsatzTV.Application/Libraries/Queries/CountMediaItemsByLibraryHandler.cs
  49. 2
      ErsatzTV.Application/Maintenance/Commands/DeleteItemsFromDatabaseHandler.cs
  50. 2
      ErsatzTV.Application/Maintenance/Commands/DeleteOrphanedArtwork.cs
  51. 2
      ErsatzTV.Application/Maintenance/Commands/DeleteOrphanedArtworkHandler.cs
  52. 2
      ErsatzTV.Application/MediaCollections/Commands/AddArtistToCollection.cs
  53. 2
      ErsatzTV.Application/MediaCollections/Commands/AddArtistToCollectionHandler.cs
  54. 2
      ErsatzTV.Application/MediaCollections/Commands/AddEpisodeToCollection.cs
  55. 6
      ErsatzTV.Application/MediaCollections/Commands/AddEpisodeToCollectionHandler.cs
  56. 2
      ErsatzTV.Application/MediaCollections/Commands/AddItemsToCollection.cs
  57. 9
      ErsatzTV.Application/MediaCollections/Commands/AddItemsToCollectionHandler.cs
  58. 2
      ErsatzTV.Application/MediaCollections/Commands/AddMovieCollection.cs
  59. 4
      ErsatzTV.Application/MediaCollections/Commands/AddMovieToCollectionHandler.cs
  60. 2
      ErsatzTV.Application/MediaCollections/Commands/AddMusicVideoToCollection.cs
  61. 6
      ErsatzTV.Application/MediaCollections/Commands/AddMusicVideoToCollectionHandler.cs
  62. 2
      ErsatzTV.Application/MediaCollections/Commands/AddOtherVideoToCollection.cs
  63. 6
      ErsatzTV.Application/MediaCollections/Commands/AddOtherVideoToCollectionHandler.cs
  64. 2
      ErsatzTV.Application/MediaCollections/Commands/AddSeasonToCollection.cs
  65. 4
      ErsatzTV.Application/MediaCollections/Commands/AddSeasonToCollectionHandler.cs
  66. 2
      ErsatzTV.Application/MediaCollections/Commands/AddShowToCollection.cs
  67. 4
      ErsatzTV.Application/MediaCollections/Commands/AddShowToCollectionHandler.cs
  68. 2
      ErsatzTV.Application/MediaCollections/Commands/AddSongToCollection.cs
  69. 2
      ErsatzTV.Application/MediaCollections/Commands/AddSongToCollectionHandler.cs
  70. 6
      ErsatzTV.Application/MediaCollections/Commands/CreateMultiCollection.cs
  71. 2
      ErsatzTV.Application/MediaCollections/Commands/DeleteCollection.cs
  72. 2
      ErsatzTV.Application/MediaCollections/Commands/DeleteCollectionHandler.cs
  73. 2
      ErsatzTV.Application/MediaCollections/Commands/DeleteMultiCollection.cs
  74. 2
      ErsatzTV.Application/MediaCollections/Commands/DeleteMultiCollectionHandler.cs
  75. 2
      ErsatzTV.Application/MediaCollections/Commands/DeleteSmartCollection.cs
  76. 2
      ErsatzTV.Application/MediaCollections/Commands/DeleteSmartCollectionHandler.cs
  77. 2
      ErsatzTV.Application/MediaCollections/Commands/DeleteTraktList.cs
  78. 6
      ErsatzTV.Application/MediaCollections/Commands/DeleteTraktListHandler.cs
  79. 2
      ErsatzTV.Application/MediaCollections/Commands/RemoveItemsFromCollection.cs
  80. 2
      ErsatzTV.Application/MediaCollections/Commands/RemoveItemsFromCollectionHandler.cs
  81. 6
      ErsatzTV.Application/MediaCollections/Commands/TraktCommandBase.cs
  82. 2
      ErsatzTV.Application/MediaCollections/Commands/UpdateCollection.cs
  83. 2
      ErsatzTV.Application/MediaCollections/Commands/UpdateCollectionCustomOrder.cs
  84. 2
      ErsatzTV.Application/MediaCollections/Commands/UpdateCollectionCustomOrderHandler.cs
  85. 2
      ErsatzTV.Application/MediaCollections/Commands/UpdateCollectionHandler.cs
  86. 8
      ErsatzTV.Application/MediaCollections/Commands/UpdateMultiCollection.cs
  87. 2
      ErsatzTV.Application/MediaCollections/Commands/UpdateMultiCollectionHandler.cs
  88. 2
      ErsatzTV.Application/MediaCollections/Commands/UpdateSmartCollectionHandler.cs
  89. 3
      ErsatzTV.Application/MediaCollections/Mapper.cs
  90. 4
      ErsatzTV.Application/MediaCollections/Queries/GetPagedCollectionsHandler.cs
  91. 4
      ErsatzTV.Application/MediaCollections/Queries/GetPagedMultiCollectionsHandler.cs
  92. 4
      ErsatzTV.Application/MediaCollections/Queries/GetPagedSmartCollectionsHandler.cs
  93. 4
      ErsatzTV.Application/MediaCollections/Queries/GetPagedTraktListsHandler.cs
  94. 4
      ErsatzTV.Application/MediaSources/Commands/ScanLocalLibraryHandler.cs
  95. 2
      ErsatzTV.Application/Movies/Queries/GetMovieByIdHandler.cs
  96. 6
      ErsatzTV.Application/Playouts/Commands/BuildPlayoutHandler.cs
  97. 2
      ErsatzTV.Application/Playouts/Commands/CreatePlayoutHandler.cs
  98. 15
      ErsatzTV.Application/Playouts/Mapper.cs
  99. 3
      ErsatzTV.Application/Playouts/Queries/GetFuturePlayoutItemsById.cs
  100. 5
      ErsatzTV.Application/Playouts/Queries/GetFuturePlayoutItemsByIdHandler.cs
  101. Some files were not shown because too many files have changed in this diff Show More

2
.config/dotnet-tools.json

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"jetbrains.resharper.globaltools": {
"version": "2021.2.2",
"version": "2022.1.0",
"commands": [
"jb"
]

6
ErsatzTV.Application/Channels/Commands/CreateChannelHandler.cs

@ -21,7 +21,7 @@ public class CreateChannelHandler : IRequestHandler<CreateChannel, Either<BaseEr @@ -21,7 +21,7 @@ public class CreateChannelHandler : IRequestHandler<CreateChannel, Either<BaseEr
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, Channel> validation = await Validate(dbContext, request);
return await validation.Apply(c => PersistChannel(dbContext, c));
return await LanguageExtensions.Apply(validation, c => PersistChannel(dbContext, c));
}
private static async Task<CreateChannelResult> PersistChannel(TvContext dbContext, Channel channel)
@ -106,7 +106,9 @@ public class CreateChannelHandler : IRequestHandler<CreateChannel, Either<BaseEr @@ -106,7 +106,9 @@ public class CreateChannelHandler : IRequestHandler<CreateChannel, Either<BaseEr
ci => string.Equals(ci.ThreeLetterISOLanguageName, lc, StringComparison.OrdinalIgnoreCase)))
.ToValidation<BaseError>("Preferred subtitle language code is invalid");
private static async Task<Validation<BaseError, string>> ValidateNumber(TvContext dbContext, CreateChannel createChannel)
private static async Task<Validation<BaseError, string>> ValidateNumber(
TvContext dbContext,
CreateChannel createChannel)
{
Option<Channel> maybeExistingChannel = await dbContext.Channels
.SelectOneAsync(c => c.Number, c => c.Number == createChannel.Number);

2
ErsatzTV.Application/Channels/Commands/UpdateChannelHandler.cs

@ -14,8 +14,8 @@ namespace ErsatzTV.Application.Channels; @@ -14,8 +14,8 @@ namespace ErsatzTV.Application.Channels;
public class UpdateChannelHandler : IRequestHandler<UpdateChannel, Either<BaseError, ChannelViewModel>>
{
private readonly ChannelWriter<ISubtitleWorkerRequest> _ffmpegWorkerChannel;
private readonly IDbContextFactory<TvContext> _dbContextFactory;
private readonly ChannelWriter<ISubtitleWorkerRequest> _ffmpegWorkerChannel;
public UpdateChannelHandler(
ChannelWriter<ISubtitleWorkerRequest> ffmpegWorkerChannel,

2
ErsatzTV.Application/Configuration/Commands/SaveConfigElementByKey.cs

@ -2,4 +2,4 @@ @@ -2,4 +2,4 @@
namespace ErsatzTV.Application.Configuration;
public record SaveConfigElementByKey(ConfigElementKey Key, string Value) : MediatR.IRequest<Unit>;
public record SaveConfigElementByKey(ConfigElementKey Key, string Value) : IRequest<Unit>;

2
ErsatzTV.Application/Configuration/Commands/SaveConfigElementByKeyHandler.cs

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
namespace ErsatzTV.Application.Configuration;
public class SaveConfigElementByKeyHandler : MediatR.IRequestHandler<SaveConfigElementByKey, Unit>
public class SaveConfigElementByKeyHandler : IRequestHandler<SaveConfigElementByKey, Unit>
{
private readonly IConfigElementRepository _configElementRepository;

2
ErsatzTV.Application/Configuration/Commands/UpdateLibraryRefreshInterval.cs

@ -2,4 +2,4 @@ @@ -2,4 +2,4 @@
namespace ErsatzTV.Application.Configuration;
public record UpdateLibraryRefreshInterval(int LibraryRefreshInterval) : MediatR.IRequest<Either<BaseError, Unit>>;
public record UpdateLibraryRefreshInterval(int LibraryRefreshInterval) : IRequest<Either<BaseError, Unit>>;

7
ErsatzTV.Application/Configuration/Commands/UpdateLibraryRefreshIntervalHandler.cs

@ -5,7 +5,7 @@ using ErsatzTV.Core.Interfaces.Repositories; @@ -5,7 +5,7 @@ using ErsatzTV.Core.Interfaces.Repositories;
namespace ErsatzTV.Application.Configuration;
public class UpdateLibraryRefreshIntervalHandler :
MediatR.IRequestHandler<UpdateLibraryRefreshInterval, Either<BaseError, Unit>>
IRequestHandler<UpdateLibraryRefreshInterval, Either<BaseError, Unit>>
{
private readonly IConfigElementRepository _configElementRepository;
@ -16,7 +16,10 @@ public class UpdateLibraryRefreshIntervalHandler : @@ -16,7 +16,10 @@ public class UpdateLibraryRefreshIntervalHandler :
UpdateLibraryRefreshInterval request,
CancellationToken cancellationToken) =>
Validate(request)
.MapT(_ => _configElementRepository.Upsert(ConfigElementKey.LibraryRefreshInterval, request.LibraryRefreshInterval))
.MapT(
_ => _configElementRepository.Upsert(
ConfigElementKey.LibraryRefreshInterval,
request.LibraryRefreshInterval))
.Bind(v => v.ToEitherAsync());
private static Task<Validation<BaseError, Unit>> Validate(UpdateLibraryRefreshInterval request) =>

2
ErsatzTV.Application/Configuration/Commands/UpdatePlayoutDaysToBuild.cs

@ -2,4 +2,4 @@ @@ -2,4 +2,4 @@
namespace ErsatzTV.Application.Configuration;
public record UpdatePlayoutDaysToBuild(int DaysToBuild) : MediatR.IRequest<Either<BaseError, Unit>>;
public record UpdatePlayoutDaysToBuild(int DaysToBuild) : IRequest<Either<BaseError, Unit>>;

2
ErsatzTV.Application/Emby/Commands/DisconnectEmby.cs

@ -2,4 +2,4 @@ @@ -2,4 +2,4 @@
namespace ErsatzTV.Application.Emby;
public record DisconnectEmby : MediatR.IRequest<Either<BaseError, Unit>>;
public record DisconnectEmby : IRequest<Either<BaseError, Unit>>;

2
ErsatzTV.Application/Emby/Commands/DisconnectEmbyHandler.cs

@ -7,7 +7,7 @@ using ErsatzTV.Core.Interfaces.Search; @@ -7,7 +7,7 @@ using ErsatzTV.Core.Interfaces.Search;
namespace ErsatzTV.Application.Emby;
public class DisconnectEmbyHandler : MediatR.IRequestHandler<DisconnectEmby, Either<BaseError, Unit>>
public class DisconnectEmbyHandler : IRequestHandler<DisconnectEmby, Either<BaseError, Unit>>
{
private readonly IEmbySecretStore _embySecretStore;
private readonly IEntityLocker _entityLocker;

2
ErsatzTV.Application/Emby/Commands/SaveEmbySecrets.cs

@ -3,4 +3,4 @@ using ErsatzTV.Core.Emby; @@ -3,4 +3,4 @@ using ErsatzTV.Core.Emby;
namespace ErsatzTV.Application.Emby;
public record SaveEmbySecrets(EmbySecrets Secrets) : MediatR.IRequest<Either<BaseError, Unit>>;
public record SaveEmbySecrets(EmbySecrets Secrets) : IRequest<Either<BaseError, Unit>>;

2
ErsatzTV.Application/Emby/Commands/SaveEmbySecretsHandler.cs

@ -6,7 +6,7 @@ using ErsatzTV.Core.Interfaces.Repositories; @@ -6,7 +6,7 @@ using ErsatzTV.Core.Interfaces.Repositories;
namespace ErsatzTV.Application.Emby;
public class SaveEmbySecretsHandler : MediatR.IRequestHandler<SaveEmbySecrets, Either<BaseError, Unit>>
public class SaveEmbySecretsHandler : IRequestHandler<SaveEmbySecrets, Either<BaseError, Unit>>
{
private readonly ChannelWriter<IEmbyBackgroundServiceRequest> _channel;
private readonly IEmbyApiClient _embyApiClient;

2
ErsatzTV.Application/Emby/Commands/SynchronizeEmbyLibraries.cs

@ -2,5 +2,5 @@ @@ -2,5 +2,5 @@
namespace ErsatzTV.Application.Emby;
public record SynchronizeEmbyLibraries(int EmbyMediaSourceId) : MediatR.IRequest<Either<BaseError, Unit>>,
public record SynchronizeEmbyLibraries(int EmbyMediaSourceId) : IRequest<Either<BaseError, Unit>>,
IEmbyBackgroundServiceRequest;

2
ErsatzTV.Application/Emby/Commands/SynchronizeEmbyLibrariesHandler.cs

@ -9,7 +9,7 @@ using Microsoft.Extensions.Logging; @@ -9,7 +9,7 @@ using Microsoft.Extensions.Logging;
namespace ErsatzTV.Application.Emby;
public class
SynchronizeEmbyLibrariesHandler : MediatR.IRequestHandler<SynchronizeEmbyLibraries, Either<BaseError, Unit>>
SynchronizeEmbyLibrariesHandler : IRequestHandler<SynchronizeEmbyLibraries, Either<BaseError, Unit>>
{
private readonly IEmbyApiClient _embyApiClient;
private readonly IEmbySecretStore _embySecretStore;

2
ErsatzTV.Application/Emby/Commands/UpdateEmbyLibraryPreferences.cs

@ -3,6 +3,6 @@ @@ -3,6 +3,6 @@
namespace ErsatzTV.Application.Emby;
public record UpdateEmbyLibraryPreferences
(List<EmbyLibraryPreference> Preferences) : MediatR.IRequest<Either<BaseError, Unit>>;
(List<EmbyLibraryPreference> Preferences) : IRequest<Either<BaseError, Unit>>;
public record EmbyLibraryPreference(int Id, bool ShouldSyncItems);

2
ErsatzTV.Application/Emby/Commands/UpdateEmbyLibraryPreferencesHandler.cs

@ -5,7 +5,7 @@ using ErsatzTV.Core.Interfaces.Search; @@ -5,7 +5,7 @@ using ErsatzTV.Core.Interfaces.Search;
namespace ErsatzTV.Application.Emby;
public class
UpdateEmbyLibraryPreferencesHandler : MediatR.IRequestHandler<UpdateEmbyLibraryPreferences,
UpdateEmbyLibraryPreferencesHandler : IRequestHandler<UpdateEmbyLibraryPreferences,
Either<BaseError, Unit>>
{
private readonly IMediaSourceRepository _mediaSourceRepository;

2
ErsatzTV.Application/Emby/Commands/UpdateEmbyPathReplacements.cs

@ -4,6 +4,6 @@ namespace ErsatzTV.Application.Emby; @@ -4,6 +4,6 @@ namespace ErsatzTV.Application.Emby;
public record UpdateEmbyPathReplacements(
int EmbyMediaSourceId,
List<EmbyPathReplacementItem> PathReplacements) : MediatR.IRequest<Either<BaseError, Unit>>;
List<EmbyPathReplacementItem> PathReplacements) : IRequest<Either<BaseError, Unit>>;
public record EmbyPathReplacementItem(int Id, string EmbyPath, string LocalPath);

2
ErsatzTV.Application/Emby/Commands/UpdateEmbyPathReplacementsHandler.cs

@ -4,7 +4,7 @@ using ErsatzTV.Core.Interfaces.Repositories; @@ -4,7 +4,7 @@ using ErsatzTV.Core.Interfaces.Repositories;
namespace ErsatzTV.Application.Emby;
public class UpdateEmbyPathReplacementsHandler : MediatR.IRequestHandler<UpdateEmbyPathReplacements,
public class UpdateEmbyPathReplacementsHandler : IRequestHandler<UpdateEmbyPathReplacements,
Either<BaseError, Unit>>
{
private readonly IMediaSourceRepository _mediaSourceRepository;

2
ErsatzTV.Application/ErsatzTV.Application.csproj

@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
<ItemGroup>
<PackageReference Include="Bugsnag" Version="3.0.1" />
<PackageReference Include="CliWrap" Version="3.4.2" />
<PackageReference Include="CliWrap" Version="3.4.3" />
<PackageReference Include="MediatR" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.1.46">

6
ErsatzTV.Application/FFmpegProfiles/Commands/CreateFFmpegProfileHandler.cs

@ -20,7 +20,7 @@ public class CreateFFmpegProfileHandler : @@ -20,7 +20,7 @@ public class CreateFFmpegProfileHandler :
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, FFmpegProfile> validation = await Validate(dbContext, request);
return await validation.Apply(profile => PersistFFmpegProfile(dbContext, profile));
return await LanguageExtensions.Apply(validation, profile => PersistFFmpegProfile(dbContext, profile));
}
private static async Task<CreateFFmpegProfileResult> PersistFFmpegProfile(
@ -32,7 +32,9 @@ public class CreateFFmpegProfileHandler : @@ -32,7 +32,9 @@ public class CreateFFmpegProfileHandler :
return new CreateFFmpegProfileResult(ffmpegProfile.Id);
}
private async Task<Validation<BaseError, FFmpegProfile>> Validate(TvContext dbContext, CreateFFmpegProfile request) =>
private async Task<Validation<BaseError, FFmpegProfile>> Validate(
TvContext dbContext,
CreateFFmpegProfile request) =>
(ValidateName(request), ValidateThreadCount(request), await ResolutionMustExist(dbContext, request))
.Apply(
(name, threadCount, resolutionId) => new FFmpegProfile

2
ErsatzTV.Application/FFmpegProfiles/Commands/DeleteFFmpegProfile.cs

@ -2,4 +2,4 @@ @@ -2,4 +2,4 @@
namespace ErsatzTV.Application.FFmpegProfiles;
public record DeleteFFmpegProfile(int FFmpegProfileId) : MediatR.IRequest<Either<BaseError, Unit>>;
public record DeleteFFmpegProfile(int FFmpegProfileId) : IRequest<Either<BaseError, Unit>>;

8
ErsatzTV.Application/FFmpegProfiles/Commands/DeleteFFmpegProfileHandler.cs

@ -6,14 +6,14 @@ using Microsoft.EntityFrameworkCore; @@ -6,14 +6,14 @@ using Microsoft.EntityFrameworkCore;
namespace ErsatzTV.Application.FFmpegProfiles;
public class DeleteFFmpegProfileHandler : IRequestHandler<DeleteFFmpegProfile, Either<BaseError, LanguageExt.Unit>>
public class DeleteFFmpegProfileHandler : IRequestHandler<DeleteFFmpegProfile, Either<BaseError, Unit>>
{
private readonly IDbContextFactory<TvContext> _dbContextFactory;
public DeleteFFmpegProfileHandler(IDbContextFactory<TvContext> dbContextFactory) =>
_dbContextFactory = dbContextFactory;
public async Task<Either<BaseError, LanguageExt.Unit>> Handle(
public async Task<Either<BaseError, Unit>> Handle(
DeleteFFmpegProfile request,
CancellationToken cancellationToken)
{
@ -22,11 +22,11 @@ public class DeleteFFmpegProfileHandler : IRequestHandler<DeleteFFmpegProfile, E @@ -22,11 +22,11 @@ public class DeleteFFmpegProfileHandler : IRequestHandler<DeleteFFmpegProfile, E
return await LanguageExtensions.Apply(validation, p => DoDeletion(dbContext, p));
}
private static async Task<LanguageExt.Unit> DoDeletion(TvContext dbContext, FFmpegProfile ffmpegProfile)
private static async Task<Unit> DoDeletion(TvContext dbContext, FFmpegProfile ffmpegProfile)
{
dbContext.FFmpegProfiles.Remove(ffmpegProfile);
await dbContext.SaveChangesAsync();
return LanguageExt.Unit.Default;
return Unit.Default;
}
private static Task<Validation<BaseError, FFmpegProfile>> FFmpegProfileMustExist(

2
ErsatzTV.Application/FFmpegProfiles/Commands/UpdateFFmpegProfileHandler.cs

@ -20,7 +20,7 @@ public class @@ -20,7 +20,7 @@ public class
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, FFmpegProfile> validation = await Validate(dbContext, request);
return await validation.Apply(p => ApplyUpdateRequest(dbContext, p, request));
return await LanguageExtensions.Apply(validation, p => ApplyUpdateRequest(dbContext, p, request));
}
private async Task<UpdateFFmpegProfileResult> ApplyUpdateRequest(

2
ErsatzTV.Application/FFmpegProfiles/Commands/UpdateFFmpegSettings.cs

@ -2,4 +2,4 @@ @@ -2,4 +2,4 @@
namespace ErsatzTV.Application.FFmpegProfiles;
public record UpdateFFmpegSettings(FFmpegSettingsViewModel Settings) : MediatR.IRequest<Either<BaseError, Unit>>;
public record UpdateFFmpegSettings(FFmpegSettingsViewModel Settings) : IRequest<Either<BaseError, Unit>>;

2
ErsatzTV.Application/FFmpegProfiles/Queries/GetFFmpegSettingsHandler.cs

@ -42,7 +42,7 @@ public class GetFFmpegSettingsHandler : IRequestHandler<GetFFmpegSettings, FFmpe @@ -42,7 +42,7 @@ public class GetFFmpegSettingsHandler : IRequestHandler<GetFFmpegSettings, FFmpe
PreferredAudioLanguageCode = await preferredAudioLanguageCode.IfNoneAsync("eng"),
HlsSegmenterIdleTimeout = await hlsSegmenterIdleTimeout.IfNoneAsync(60),
WorkAheadSegmenterLimit = await workAheadSegmenterLimit.IfNoneAsync(1),
InitialSegmentCount = await initialSegmentCount.IfNoneAsync(1),
InitialSegmentCount = await initialSegmentCount.IfNoneAsync(1)
};
foreach (int watermarkId in watermark)

2
ErsatzTV.Application/Filler/Commands/DeleteFillerPreset.cs

@ -2,4 +2,4 @@ @@ -2,4 +2,4 @@
namespace ErsatzTV.Application.Filler;
public record DeleteFillerPreset(int FillerPresetId) : IRequest<Either<BaseError, LanguageExt.Unit>>;
public record DeleteFillerPreset(int FillerPresetId) : IRequest<Either<BaseError, Unit>>;

4
ErsatzTV.Application/Filler/Commands/UpdateFillerPresetHandler.cs

@ -10,10 +10,8 @@ public class UpdateFillerPresetHandler : IRequestHandler<UpdateFillerPreset, Eit @@ -10,10 +10,8 @@ public class UpdateFillerPresetHandler : IRequestHandler<UpdateFillerPreset, Eit
{
private readonly IDbContextFactory<TvContext> _dbContextFactory;
public UpdateFillerPresetHandler(IDbContextFactory<TvContext> dbContextFactory)
{
public UpdateFillerPresetHandler(IDbContextFactory<TvContext> dbContextFactory) =>
_dbContextFactory = dbContextFactory;
}
public async Task<Either<BaseError, Unit>> Handle(UpdateFillerPreset request, CancellationToken cancellationToken)
{

4
ErsatzTV.Application/Filler/Queries/GetPagedFillerPresetsHandler.cs

@ -9,10 +9,8 @@ public class GetPagedFillerPresetsHandler : IRequestHandler<GetPagedFillerPreset @@ -9,10 +9,8 @@ public class GetPagedFillerPresetsHandler : IRequestHandler<GetPagedFillerPreset
{
private readonly IDbContextFactory<TvContext> _dbContextFactory;
public GetPagedFillerPresetsHandler(IDbContextFactory<TvContext> dbContextFactory)
{
public GetPagedFillerPresetsHandler(IDbContextFactory<TvContext> dbContextFactory) =>
_dbContextFactory = dbContextFactory;
}
public async Task<PagedFillerPresetsViewModel> Handle(
GetPagedFillerPresets request,

2
ErsatzTV.Application/HDHR/Commands/UpdateHDHRTunerCount.cs

@ -2,4 +2,4 @@ @@ -2,4 +2,4 @@
namespace ErsatzTV.Application.HDHR;
public record UpdateHDHRTunerCount(int TunerCount) : MediatR.IRequest<Either<BaseError, Unit>>;
public record UpdateHDHRTunerCount(int TunerCount) : IRequest<Either<BaseError, Unit>>;

2
ErsatzTV.Application/HDHR/Commands/UpdateHDHRTunerCountHandler.cs

@ -4,7 +4,7 @@ using ErsatzTV.Core.Interfaces.Repositories; @@ -4,7 +4,7 @@ using ErsatzTV.Core.Interfaces.Repositories;
namespace ErsatzTV.Application.HDHR;
public class UpdateHDHRTunerCountHandler : MediatR.IRequestHandler<UpdateHDHRTunerCount, Either<BaseError, Unit>>
public class UpdateHDHRTunerCountHandler : IRequestHandler<UpdateHDHRTunerCount, Either<BaseError, Unit>>
{
private readonly IConfigElementRepository _configElementRepository;

4
ErsatzTV.Application/Images/Queries/GetCachedImagePathHandler.cs

@ -12,9 +12,9 @@ public class @@ -12,9 +12,9 @@ public class
GetCachedImagePathHandler : IRequestHandler<GetCachedImagePath, Either<BaseError, CachedImagePathViewModel>>
{
private static readonly MimeTypes MimeTypes = new();
private readonly IImageCache _imageCache;
private readonly IFFmpegProcessService _ffmpegProcessService;
private readonly IConfigElementRepository _configElementRepository;
private readonly IFFmpegProcessService _ffmpegProcessService;
private readonly IImageCache _imageCache;
public GetCachedImagePathHandler(
IImageCache imageCache,

2
ErsatzTV.Application/Jellyfin/Commands/DisconnectJellyfin.cs

@ -2,4 +2,4 @@ @@ -2,4 +2,4 @@
namespace ErsatzTV.Application.Jellyfin;
public record DisconnectJellyfin : MediatR.IRequest<Either<BaseError, Unit>>;
public record DisconnectJellyfin : IRequest<Either<BaseError, Unit>>;

2
ErsatzTV.Application/Jellyfin/Commands/DisconnectJellyfinHandler.cs

@ -7,7 +7,7 @@ using ErsatzTV.Core.Interfaces.Search; @@ -7,7 +7,7 @@ using ErsatzTV.Core.Interfaces.Search;
namespace ErsatzTV.Application.Jellyfin;
public class DisconnectJellyfinHandler : MediatR.IRequestHandler<DisconnectJellyfin, Either<BaseError, Unit>>
public class DisconnectJellyfinHandler : IRequestHandler<DisconnectJellyfin, Either<BaseError, Unit>>
{
private readonly IEntityLocker _entityLocker;
private readonly IJellyfinSecretStore _jellyfinSecretStore;

2
ErsatzTV.Application/Jellyfin/Commands/SaveJellyfinSecrets.cs

@ -3,4 +3,4 @@ using ErsatzTV.Core.Jellyfin; @@ -3,4 +3,4 @@ using ErsatzTV.Core.Jellyfin;
namespace ErsatzTV.Application.Jellyfin;
public record SaveJellyfinSecrets(JellyfinSecrets Secrets) : MediatR.IRequest<Either<BaseError, Unit>>;
public record SaveJellyfinSecrets(JellyfinSecrets Secrets) : IRequest<Either<BaseError, Unit>>;

2
ErsatzTV.Application/Jellyfin/Commands/SaveJellyfinSecretsHandler.cs

@ -6,7 +6,7 @@ using ErsatzTV.Core.Jellyfin; @@ -6,7 +6,7 @@ using ErsatzTV.Core.Jellyfin;
namespace ErsatzTV.Application.Jellyfin;
public class SaveJellyfinSecretsHandler : MediatR.IRequestHandler<SaveJellyfinSecrets, Either<BaseError, Unit>>
public class SaveJellyfinSecretsHandler : IRequestHandler<SaveJellyfinSecrets, Either<BaseError, Unit>>
{
private readonly ChannelWriter<IJellyfinBackgroundServiceRequest> _channel;
private readonly IJellyfinApiClient _jellyfinApiClient;

2
ErsatzTV.Application/Jellyfin/Commands/SynchronizeJellyfinAdminUserId.cs

@ -2,5 +2,5 @@ @@ -2,5 +2,5 @@
namespace ErsatzTV.Application.Jellyfin;
public record SynchronizeJellyfinAdminUserId(int JellyfinMediaSourceId) : MediatR.IRequest<Either<BaseError, Unit>>,
public record SynchronizeJellyfinAdminUserId(int JellyfinMediaSourceId) : IRequest<Either<BaseError, Unit>>,
IJellyfinBackgroundServiceRequest;

2
ErsatzTV.Application/Jellyfin/Commands/SynchronizeJellyfinAdminUserIdHandler.cs

@ -9,7 +9,7 @@ using Microsoft.Extensions.Logging; @@ -9,7 +9,7 @@ using Microsoft.Extensions.Logging;
namespace ErsatzTV.Application.Jellyfin;
public class
SynchronizeJellyfinAdminUserIdHandler : MediatR.IRequestHandler<SynchronizeJellyfinAdminUserId,
SynchronizeJellyfinAdminUserIdHandler : IRequestHandler<SynchronizeJellyfinAdminUserId,
Either<BaseError, Unit>>
{
private readonly IJellyfinApiClient _jellyfinApiClient;

2
ErsatzTV.Application/Jellyfin/Commands/SynchronizeJellyfinLibraries.cs

@ -2,5 +2,5 @@ @@ -2,5 +2,5 @@
namespace ErsatzTV.Application.Jellyfin;
public record SynchronizeJellyfinLibraries(int JellyfinMediaSourceId) : MediatR.IRequest<Either<BaseError, Unit>>,
public record SynchronizeJellyfinLibraries(int JellyfinMediaSourceId) : IRequest<Either<BaseError, Unit>>,
IJellyfinBackgroundServiceRequest;

2
ErsatzTV.Application/Jellyfin/Commands/SynchronizeJellyfinLibrariesHandler.cs

@ -9,7 +9,7 @@ using Microsoft.Extensions.Logging; @@ -9,7 +9,7 @@ using Microsoft.Extensions.Logging;
namespace ErsatzTV.Application.Jellyfin;
public class
SynchronizeJellyfinLibrariesHandler : MediatR.IRequestHandler<SynchronizeJellyfinLibraries,
SynchronizeJellyfinLibrariesHandler : IRequestHandler<SynchronizeJellyfinLibraries,
Either<BaseError, Unit>>
{

2
ErsatzTV.Application/Jellyfin/Commands/UpdateJellyfinLibraryPreferences.cs

@ -3,6 +3,6 @@ @@ -3,6 +3,6 @@
namespace ErsatzTV.Application.Jellyfin;
public record UpdateJellyfinLibraryPreferences
(List<JellyfinLibraryPreference> Preferences) : MediatR.IRequest<Either<BaseError, Unit>>;
(List<JellyfinLibraryPreference> Preferences) : IRequest<Either<BaseError, Unit>>;
public record JellyfinLibraryPreference(int Id, bool ShouldSyncItems);

2
ErsatzTV.Application/Jellyfin/Commands/UpdateJellyfinLibraryPreferencesHandler.cs

@ -5,7 +5,7 @@ using ErsatzTV.Core.Interfaces.Search; @@ -5,7 +5,7 @@ using ErsatzTV.Core.Interfaces.Search;
namespace ErsatzTV.Application.Jellyfin;
public class
UpdateJellyfinLibraryPreferencesHandler : MediatR.IRequestHandler<UpdateJellyfinLibraryPreferences,
UpdateJellyfinLibraryPreferencesHandler : IRequestHandler<UpdateJellyfinLibraryPreferences,
Either<BaseError, Unit>>
{
private readonly IMediaSourceRepository _mediaSourceRepository;

2
ErsatzTV.Application/Jellyfin/Commands/UpdateJellyfinPathReplacements.cs

@ -4,6 +4,6 @@ namespace ErsatzTV.Application.Jellyfin; @@ -4,6 +4,6 @@ namespace ErsatzTV.Application.Jellyfin;
public record UpdateJellyfinPathReplacements(
int JellyfinMediaSourceId,
List<JellyfinPathReplacementItem> PathReplacements) : MediatR.IRequest<Either<BaseError, Unit>>;
List<JellyfinPathReplacementItem> PathReplacements) : IRequest<Either<BaseError, Unit>>;
public record JellyfinPathReplacementItem(int Id, string JellyfinPath, string LocalPath);

2
ErsatzTV.Application/Jellyfin/Commands/UpdateJellyfinPathReplacementsHandler.cs

@ -4,7 +4,7 @@ using ErsatzTV.Core.Interfaces.Repositories; @@ -4,7 +4,7 @@ using ErsatzTV.Core.Interfaces.Repositories;
namespace ErsatzTV.Application.Jellyfin;
public class UpdateJellyfinPathReplacementsHandler : MediatR.IRequestHandler<UpdateJellyfinPathReplacements,
public class UpdateJellyfinPathReplacementsHandler : IRequestHandler<UpdateJellyfinPathReplacements,
Either<BaseError, Unit>>
{
private readonly IMediaSourceRepository _mediaSourceRepository;

4
ErsatzTV.Application/Libraries/Commands/CreateLocalLibraryHandler.cs

@ -12,9 +12,9 @@ namespace ErsatzTV.Application.Libraries; @@ -12,9 +12,9 @@ namespace ErsatzTV.Application.Libraries;
public class CreateLocalLibraryHandler : LocalLibraryHandlerBase,
IRequestHandler<CreateLocalLibrary, Either<BaseError, LocalLibraryViewModel>>
{
private readonly ChannelWriter<IBackgroundServiceRequest> _workerChannel;
private readonly IEntityLocker _entityLocker;
private readonly IDbContextFactory<TvContext> _dbContextFactory;
private readonly IEntityLocker _entityLocker;
private readonly ChannelWriter<IBackgroundServiceRequest> _workerChannel;
public CreateLocalLibraryHandler(
ChannelWriter<IBackgroundServiceRequest> workerChannel,

2
ErsatzTV.Application/Libraries/Commands/DeleteLocalLibraryHandler.cs

@ -28,7 +28,7 @@ public class DeleteLocalLibraryHandler : LocalLibraryHandlerBase, @@ -28,7 +28,7 @@ public class DeleteLocalLibraryHandler : LocalLibraryHandlerBase,
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, LocalLibrary> validation = await LocalLibraryMustExist(dbContext, request);
return await validation.Apply(localLibrary => DoDeletion(dbContext, localLibrary));
return await LanguageExtensions.Apply(validation, localLibrary => DoDeletion(dbContext, localLibrary));
}
private async Task<Unit> DoDeletion(TvContext dbContext, LocalLibrary localLibrary)

6
ErsatzTV.Application/Libraries/Commands/MoveLocalLibraryPathHandler.cs

@ -12,10 +12,10 @@ namespace ErsatzTV.Application.Libraries; @@ -12,10 +12,10 @@ namespace ErsatzTV.Application.Libraries;
public class MoveLocalLibraryPathHandler : IRequestHandler<MoveLocalLibraryPath, Either<BaseError, Unit>>
{
private readonly ISearchIndex _searchIndex;
private readonly ISearchRepository _searchRepository;
private readonly IDbContextFactory<TvContext> _dbContextFactory;
private readonly ILogger<MoveLocalLibraryPathHandler> _logger;
private readonly ISearchIndex _searchIndex;
private readonly ISearchRepository _searchRepository;
public MoveLocalLibraryPathHandler(
ISearchIndex searchIndex,
@ -35,7 +35,7 @@ public class MoveLocalLibraryPathHandler : IRequestHandler<MoveLocalLibraryPath, @@ -35,7 +35,7 @@ public class MoveLocalLibraryPathHandler : IRequestHandler<MoveLocalLibraryPath,
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, Parameters> validation = await Validate(dbContext, request);
return await validation.Apply(parameters => MovePath(dbContext, parameters));
return await LanguageExtensions.Apply(validation, parameters => MovePath(dbContext, parameters));
}
private async Task<Unit> MovePath(TvContext dbContext, Parameters parameters)

14
ErsatzTV.Application/Libraries/Commands/UpdateLocalLibraryHandler.cs

@ -14,10 +14,10 @@ namespace ErsatzTV.Application.Libraries; @@ -14,10 +14,10 @@ namespace ErsatzTV.Application.Libraries;
public class UpdateLocalLibraryHandler : LocalLibraryHandlerBase,
IRequestHandler<UpdateLocalLibrary, Either<BaseError, LocalLibraryViewModel>>
{
private readonly ChannelWriter<IBackgroundServiceRequest> _workerChannel;
private readonly IDbContextFactory<TvContext> _dbContextFactory;
private readonly IEntityLocker _entityLocker;
private readonly ISearchIndex _searchIndex;
private readonly IDbContextFactory<TvContext> _dbContextFactory;
private readonly ChannelWriter<IBackgroundServiceRequest> _workerChannel;
public UpdateLocalLibraryHandler(
ChannelWriter<IBackgroundServiceRequest> workerChannel,
@ -105,12 +105,10 @@ public class UpdateLocalLibraryHandler : LocalLibraryHandlerBase, @@ -105,12 +105,10 @@ public class UpdateLocalLibraryHandler : LocalLibraryHandlerBase,
})
.Map(o => o.ToValidation<BaseError>("LocalLibrary does not exist."));
private record Parameters(LocalLibrary Existing, LocalLibrary Incoming);
private static string NormalizePath(string path)
{
return Path.GetFullPath(new Uri(path).LocalPath)
private static string NormalizePath(string path) =>
Path.GetFullPath(new Uri(path).LocalPath)
.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)
.ToUpperInvariant();
}
private record Parameters(LocalLibrary Existing, LocalLibrary Incoming);
}

4
ErsatzTV.Application/Libraries/Queries/CountMediaItemsByLibraryHandler.cs

@ -8,10 +8,8 @@ public class CountMediaItemsByLibraryHandler : IRequestHandler<CountMediaItemsBy @@ -8,10 +8,8 @@ public class CountMediaItemsByLibraryHandler : IRequestHandler<CountMediaItemsBy
{
private readonly IDbContextFactory<TvContext> _dbContextFactory;
public CountMediaItemsByLibraryHandler(IDbContextFactory<TvContext> dbContextFactory)
{
public CountMediaItemsByLibraryHandler(IDbContextFactory<TvContext> dbContextFactory) =>
_dbContextFactory = dbContextFactory;
}
public async Task<int> Handle(CountMediaItemsByLibrary request, CancellationToken cancellationToken)
{

2
ErsatzTV.Application/Maintenance/Commands/DeleteItemsFromDatabaseHandler.cs

@ -5,7 +5,7 @@ using ErsatzTV.Core.Interfaces.Search; @@ -5,7 +5,7 @@ using ErsatzTV.Core.Interfaces.Search;
namespace ErsatzTV.Application.Maintenance;
public class
DeleteItemsFromDatabaseHandler : MediatR.IRequestHandler<DeleteItemsFromDatabase, Either<BaseError, Unit>>
DeleteItemsFromDatabaseHandler : IRequestHandler<DeleteItemsFromDatabase, Either<BaseError, Unit>>
{
private readonly IMediaItemRepository _mediaItemRepository;
private readonly ISearchIndex _searchIndex;

2
ErsatzTV.Application/Maintenance/Commands/DeleteOrphanedArtwork.cs

@ -2,4 +2,4 @@ @@ -2,4 +2,4 @@
namespace ErsatzTV.Application.Maintenance;
public record DeleteOrphanedArtwork : MediatR.IRequest<Either<BaseError, Unit>>, IBackgroundServiceRequest;
public record DeleteOrphanedArtwork : IRequest<Either<BaseError, Unit>>, IBackgroundServiceRequest;

2
ErsatzTV.Application/Maintenance/Commands/DeleteOrphanedArtworkHandler.cs

@ -3,7 +3,7 @@ using ErsatzTV.Core.Interfaces.Repositories; @@ -3,7 +3,7 @@ using ErsatzTV.Core.Interfaces.Repositories;
namespace ErsatzTV.Application.Maintenance;
public class DeleteOrphanedArtworkHandler : MediatR.IRequestHandler<DeleteOrphanedArtwork, Either<BaseError, Unit>>
public class DeleteOrphanedArtworkHandler : IRequestHandler<DeleteOrphanedArtwork, Either<BaseError, Unit>>
{
private readonly IArtworkRepository _artworkRepository;

2
ErsatzTV.Application/MediaCollections/Commands/AddArtistToCollection.cs

@ -3,4 +3,4 @@ @@ -3,4 +3,4 @@
namespace ErsatzTV.Application.MediaCollections;
public record AddArtistToCollection
(int CollectionId, int ArtistId) : MediatR.IRequest<Either<BaseError, Unit>>;
(int CollectionId, int ArtistId) : IRequest<Either<BaseError, Unit>>;

2
ErsatzTV.Application/MediaCollections/Commands/AddArtistToCollectionHandler.cs

@ -33,7 +33,7 @@ public class AddArtistToCollectionHandler : @@ -33,7 +33,7 @@ public class AddArtistToCollectionHandler :
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, Parameters> validation = await Validate(dbContext, request);
return await validation.Apply(parameters => ApplyAddArtistRequest(dbContext, parameters));
return await LanguageExtensions.Apply(validation, parameters => ApplyAddArtistRequest(dbContext, parameters));
}
private async Task<Unit> ApplyAddArtistRequest(TvContext dbContext, Parameters parameters)

2
ErsatzTV.Application/MediaCollections/Commands/AddEpisodeToCollection.cs

@ -2,4 +2,4 @@ @@ -2,4 +2,4 @@
namespace ErsatzTV.Application.MediaCollections;
public record AddEpisodeToCollection(int CollectionId, int EpisodeId) : MediatR.IRequest<Either<BaseError, Unit>>;
public record AddEpisodeToCollection(int CollectionId, int EpisodeId) : IRequest<Either<BaseError, Unit>>;

6
ErsatzTV.Application/MediaCollections/Commands/AddEpisodeToCollectionHandler.cs

@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore; @@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore;
namespace ErsatzTV.Application.MediaCollections;
public class AddEpisodeToCollectionHandler :
MediatR.IRequestHandler<AddEpisodeToCollection, Either<BaseError, Unit>>
IRequestHandler<AddEpisodeToCollection, Either<BaseError, Unit>>
{
private readonly ChannelWriter<IBackgroundServiceRequest> _channel;
private readonly IDbContextFactory<TvContext> _dbContextFactory;
@ -33,7 +33,9 @@ public class AddEpisodeToCollectionHandler : @@ -33,7 +33,9 @@ public class AddEpisodeToCollectionHandler :
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, Parameters> validation = await Validate(dbContext, request);
return await validation.Apply(parameters => ApplyAddTelevisionEpisodeRequest(dbContext, parameters));
return await LanguageExtensions.Apply(
validation,
parameters => ApplyAddTelevisionEpisodeRequest(dbContext, parameters));
}
private async Task<Unit> ApplyAddTelevisionEpisodeRequest(TvContext dbContext, Parameters parameters)

2
ErsatzTV.Application/MediaCollections/Commands/AddItemsToCollection.cs

@ -12,4 +12,4 @@ public record AddItemsToCollection @@ -12,4 +12,4 @@ public record AddItemsToCollection
List<int> ArtistIds,
List<int> MusicVideoIds,
List<int> OtherVideoIds,
List<int> SongIds) : MediatR.IRequest<Either<BaseError, Unit>>;
List<int> SongIds) : IRequest<Either<BaseError, Unit>>;

9
ErsatzTV.Application/MediaCollections/Commands/AddItemsToCollectionHandler.cs

@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore; @@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore;
namespace ErsatzTV.Application.MediaCollections;
public class AddItemsToCollectionHandler :
MediatR.IRequestHandler<AddItemsToCollection, Either<BaseError, Unit>>
IRequestHandler<AddItemsToCollection, Either<BaseError, Unit>>
{
private readonly ChannelWriter<IBackgroundServiceRequest> _channel;
private readonly IDbContextFactory<TvContext> _dbContextFactory;
@ -39,10 +39,13 @@ public class AddItemsToCollectionHandler : @@ -39,10 +39,13 @@ public class AddItemsToCollectionHandler :
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, Collection> validation = await Validate(dbContext, request);
return await validation.Apply(c => ApplyAddItemsRequest(dbContext, c, request));
return await LanguageExtensions.Apply(validation, c => ApplyAddItemsRequest(dbContext, c, request));
}
private async Task<Unit> ApplyAddItemsRequest(TvContext dbContext, Collection collection, AddItemsToCollection request)
private async Task<Unit> ApplyAddItemsRequest(
TvContext dbContext,
Collection collection,
AddItemsToCollection request)
{
var allItems = request.MovieIds
.Append(request.ShowIds)

2
ErsatzTV.Application/MediaCollections/Commands/AddMovieCollection.cs

@ -2,4 +2,4 @@ @@ -2,4 +2,4 @@
namespace ErsatzTV.Application.MediaCollections;
public record AddMovieToCollection(int CollectionId, int MovieId) : MediatR.IRequest<Either<BaseError, Unit>>;
public record AddMovieToCollection(int CollectionId, int MovieId) : IRequest<Either<BaseError, Unit>>;

4
ErsatzTV.Application/MediaCollections/Commands/AddMovieToCollectionHandler.cs

@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore; @@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore;
namespace ErsatzTV.Application.MediaCollections;
public class AddMovieToCollectionHandler :
MediatR.IRequestHandler<AddMovieToCollection, Either<BaseError, Unit>>
IRequestHandler<AddMovieToCollection, Either<BaseError, Unit>>
{
private readonly ChannelWriter<IBackgroundServiceRequest> _channel;
private readonly IDbContextFactory<TvContext> _dbContextFactory;
@ -33,7 +33,7 @@ public class AddMovieToCollectionHandler : @@ -33,7 +33,7 @@ public class AddMovieToCollectionHandler :
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, Parameters> validation = await Validate(dbContext, request);
return await validation.Apply(parameters => ApplyAddMovieRequest(dbContext, parameters));
return await LanguageExtensions.Apply(validation, parameters => ApplyAddMovieRequest(dbContext, parameters));
}
private async Task<Unit> ApplyAddMovieRequest(TvContext dbContext, Parameters parameters)

2
ErsatzTV.Application/MediaCollections/Commands/AddMusicVideoToCollection.cs

@ -3,4 +3,4 @@ @@ -3,4 +3,4 @@
namespace ErsatzTV.Application.MediaCollections;
public record AddMusicVideoToCollection
(int CollectionId, int MusicVideoId) : MediatR.IRequest<Either<BaseError, Unit>>;
(int CollectionId, int MusicVideoId) : IRequest<Either<BaseError, Unit>>;

6
ErsatzTV.Application/MediaCollections/Commands/AddMusicVideoToCollectionHandler.cs

@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore; @@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore;
namespace ErsatzTV.Application.MediaCollections;
public class AddMusicVideoToCollectionHandler :
MediatR.IRequestHandler<AddMusicVideoToCollection, Either<BaseError, Unit>>
IRequestHandler<AddMusicVideoToCollection, Either<BaseError, Unit>>
{
private readonly ChannelWriter<IBackgroundServiceRequest> _channel;
private readonly IDbContextFactory<TvContext> _dbContextFactory;
@ -33,7 +33,9 @@ public class AddMusicVideoToCollectionHandler : @@ -33,7 +33,9 @@ public class AddMusicVideoToCollectionHandler :
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, Parameters> validation = await Validate(dbContext, request);
return await validation.Apply(parameters => ApplyAddMusicVideoRequest(dbContext, parameters));
return await LanguageExtensions.Apply(
validation,
parameters => ApplyAddMusicVideoRequest(dbContext, parameters));
}
private async Task<Unit> ApplyAddMusicVideoRequest(TvContext dbContext, Parameters parameters)

2
ErsatzTV.Application/MediaCollections/Commands/AddOtherVideoToCollection.cs

@ -3,4 +3,4 @@ @@ -3,4 +3,4 @@
namespace ErsatzTV.Application.MediaCollections;
public record AddOtherVideoToCollection
(int CollectionId, int OtherVideoId) : MediatR.IRequest<Either<BaseError, Unit>>;
(int CollectionId, int OtherVideoId) : IRequest<Either<BaseError, Unit>>;

6
ErsatzTV.Application/MediaCollections/Commands/AddOtherVideoToCollectionHandler.cs

@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore; @@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore;
namespace ErsatzTV.Application.MediaCollections;
public class AddOtherVideoToCollectionHandler :
MediatR.IRequestHandler<AddOtherVideoToCollection, Either<BaseError, Unit>>
IRequestHandler<AddOtherVideoToCollection, Either<BaseError, Unit>>
{
private readonly ChannelWriter<IBackgroundServiceRequest> _channel;
private readonly IDbContextFactory<TvContext> _dbContextFactory;
@ -33,7 +33,9 @@ public class AddOtherVideoToCollectionHandler : @@ -33,7 +33,9 @@ public class AddOtherVideoToCollectionHandler :
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, Parameters> validation = await Validate(dbContext, request);
return await validation.Apply(parameters => ApplyAddOtherVideoRequest(dbContext, parameters));
return await LanguageExtensions.Apply(
validation,
parameters => ApplyAddOtherVideoRequest(dbContext, parameters));
}
private async Task<Unit> ApplyAddOtherVideoRequest(TvContext dbContext, Parameters parameters)

2
ErsatzTV.Application/MediaCollections/Commands/AddSeasonToCollection.cs

@ -2,4 +2,4 @@ @@ -2,4 +2,4 @@
namespace ErsatzTV.Application.MediaCollections;
public record AddSeasonToCollection(int CollectionId, int SeasonId) : MediatR.IRequest<Either<BaseError, Unit>>;
public record AddSeasonToCollection(int CollectionId, int SeasonId) : IRequest<Either<BaseError, Unit>>;

4
ErsatzTV.Application/MediaCollections/Commands/AddSeasonToCollectionHandler.cs

@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore; @@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore;
namespace ErsatzTV.Application.MediaCollections;
public class AddSeasonToCollectionHandler :
MediatR.IRequestHandler<AddSeasonToCollection, Either<BaseError, Unit>>
IRequestHandler<AddSeasonToCollection, Either<BaseError, Unit>>
{
private readonly ChannelWriter<IBackgroundServiceRequest> _channel;
private readonly IDbContextFactory<TvContext> _dbContextFactory;
@ -33,7 +33,7 @@ public class AddSeasonToCollectionHandler : @@ -33,7 +33,7 @@ public class AddSeasonToCollectionHandler :
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, Parameters> validation = await Validate(dbContext, request);
return await validation.Apply(parameters => ApplyAddSeasonRequest(dbContext, parameters));
return await LanguageExtensions.Apply(validation, parameters => ApplyAddSeasonRequest(dbContext, parameters));
}
private async Task<Unit> ApplyAddSeasonRequest(TvContext dbContext, Parameters parameters)

2
ErsatzTV.Application/MediaCollections/Commands/AddShowToCollection.cs

@ -2,4 +2,4 @@ @@ -2,4 +2,4 @@
namespace ErsatzTV.Application.MediaCollections;
public record AddShowToCollection(int CollectionId, int ShowId) : MediatR.IRequest<Either<BaseError, Unit>>;
public record AddShowToCollection(int CollectionId, int ShowId) : IRequest<Either<BaseError, Unit>>;

4
ErsatzTV.Application/MediaCollections/Commands/AddShowToCollectionHandler.cs

@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore; @@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore;
namespace ErsatzTV.Application.MediaCollections;
public class AddShowToCollectionHandler :
MediatR.IRequestHandler<AddShowToCollection, Either<BaseError, Unit>>
IRequestHandler<AddShowToCollection, Either<BaseError, Unit>>
{
private readonly ChannelWriter<IBackgroundServiceRequest> _channel;
private readonly IDbContextFactory<TvContext> _dbContextFactory;
@ -33,7 +33,7 @@ public class AddShowToCollectionHandler : @@ -33,7 +33,7 @@ public class AddShowToCollectionHandler :
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, Parameters> validation = await Validate(dbContext, request);
return await validation.Apply(parameters => ApplyAddShowRequest(dbContext, parameters));
return await LanguageExtensions.Apply(validation, parameters => ApplyAddShowRequest(dbContext, parameters));
}
private async Task<Unit> ApplyAddShowRequest(TvContext dbContext, Parameters parameters)

2
ErsatzTV.Application/MediaCollections/Commands/AddSongToCollection.cs

@ -3,4 +3,4 @@ @@ -3,4 +3,4 @@
namespace ErsatzTV.Application.MediaCollections;
public record AddSongToCollection
(int CollectionId, int SongId) : MediatR.IRequest<Either<BaseError, Unit>>;
(int CollectionId, int SongId) : IRequest<Either<BaseError, Unit>>;

2
ErsatzTV.Application/MediaCollections/Commands/AddSongToCollectionHandler.cs

@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore; @@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore;
namespace ErsatzTV.Application.MediaCollections;
public class AddSongToCollectionHandler :
MediatR.IRequestHandler<AddSongToCollection, Either<BaseError, Unit>>
IRequestHandler<AddSongToCollection, Either<BaseError, Unit>>
{
private readonly ChannelWriter<IBackgroundServiceRequest> _channel;
private readonly IDbContextFactory<TvContext> _dbContextFactory;

6
ErsatzTV.Application/MediaCollections/Commands/CreateMultiCollection.cs

@ -3,7 +3,11 @@ using ErsatzTV.Core.Domain; @@ -3,7 +3,11 @@ using ErsatzTV.Core.Domain;
namespace ErsatzTV.Application.MediaCollections;
public record CreateMultiCollectionItem(int? CollectionId, int? SmartCollectionId, bool ScheduleAsGroup, PlaybackOrder PlaybackOrder);
public record CreateMultiCollectionItem(
int? CollectionId,
int? SmartCollectionId,
bool ScheduleAsGroup,
PlaybackOrder PlaybackOrder);
public record CreateMultiCollection
(string Name, List<CreateMultiCollectionItem> Items) : IRequest<Either<BaseError, MultiCollectionViewModel>>;

2
ErsatzTV.Application/MediaCollections/Commands/DeleteCollection.cs

@ -2,4 +2,4 @@ @@ -2,4 +2,4 @@
namespace ErsatzTV.Application.MediaCollections;
public record DeleteCollection(int CollectionId) : IRequest<Either<BaseError, LanguageExt.Unit>>;
public record DeleteCollection(int CollectionId) : IRequest<Either<BaseError, Unit>>;

2
ErsatzTV.Application/MediaCollections/Commands/DeleteCollectionHandler.cs

@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore; @@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore;
namespace ErsatzTV.Application.MediaCollections;
public class DeleteCollectionHandler : MediatR.IRequestHandler<DeleteCollection, Either<BaseError, Unit>>
public class DeleteCollectionHandler : IRequestHandler<DeleteCollection, Either<BaseError, Unit>>
{
private readonly IDbContextFactory<TvContext> _dbContextFactory;

2
ErsatzTV.Application/MediaCollections/Commands/DeleteMultiCollection.cs

@ -2,4 +2,4 @@ @@ -2,4 +2,4 @@
namespace ErsatzTV.Application.MediaCollections;
public record DeleteMultiCollection(int MultiCollectionId) : MediatR.IRequest<Either<BaseError, Unit>>;
public record DeleteMultiCollection(int MultiCollectionId) : IRequest<Either<BaseError, Unit>>;

2
ErsatzTV.Application/MediaCollections/Commands/DeleteMultiCollectionHandler.cs

@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore; @@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore;
namespace ErsatzTV.Application.MediaCollections;
public class DeleteMultiCollectionHandler : MediatR.IRequestHandler<DeleteMultiCollection, Either<BaseError, Unit>>
public class DeleteMultiCollectionHandler : IRequestHandler<DeleteMultiCollection, Either<BaseError, Unit>>
{
private readonly IDbContextFactory<TvContext> _dbContextFactory;

2
ErsatzTV.Application/MediaCollections/Commands/DeleteSmartCollection.cs

@ -2,4 +2,4 @@ @@ -2,4 +2,4 @@
namespace ErsatzTV.Application.MediaCollections;
public record DeleteSmartCollection(int SmartCollectionId) : MediatR.IRequest<Either<BaseError, Unit>>;
public record DeleteSmartCollection(int SmartCollectionId) : IRequest<Either<BaseError, Unit>>;

2
ErsatzTV.Application/MediaCollections/Commands/DeleteSmartCollectionHandler.cs

@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore; @@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore;
namespace ErsatzTV.Application.MediaCollections;
public class DeleteSmartCollectionHandler : MediatR.IRequestHandler<DeleteSmartCollection, Either<BaseError, Unit>>
public class DeleteSmartCollectionHandler : IRequestHandler<DeleteSmartCollection, Either<BaseError, Unit>>
{
private readonly IDbContextFactory<TvContext> _dbContextFactory;

2
ErsatzTV.Application/MediaCollections/Commands/DeleteTraktList.cs

@ -2,5 +2,5 @@ @@ -2,5 +2,5 @@
namespace ErsatzTV.Application.MediaCollections;
public record DeleteTraktList(int TraktListId) : IRequest<Either<BaseError, LanguageExt.Unit>>,
public record DeleteTraktList(int TraktListId) : IRequest<Either<BaseError, Unit>>,
IBackgroundServiceRequest;

6
ErsatzTV.Application/MediaCollections/Commands/DeleteTraktListHandler.cs

@ -10,12 +10,12 @@ using Microsoft.Extensions.Logging; @@ -10,12 +10,12 @@ using Microsoft.Extensions.Logging;
namespace ErsatzTV.Application.MediaCollections;
public class DeleteTraktListHandler : TraktCommandBase, MediatR.IRequestHandler<DeleteTraktList, Either<BaseError, Unit>>
public class DeleteTraktListHandler : TraktCommandBase, IRequestHandler<DeleteTraktList, Either<BaseError, Unit>>
{
private readonly ISearchRepository _searchRepository;
private readonly ISearchIndex _searchIndex;
private readonly IDbContextFactory<TvContext> _dbContextFactory;
private readonly IEntityLocker _entityLocker;
private readonly ISearchIndex _searchIndex;
private readonly ISearchRepository _searchRepository;
public DeleteTraktListHandler(
ITraktApiClient traktApiClient,

2
ErsatzTV.Application/MediaCollections/Commands/RemoveItemsFromCollection.cs

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
namespace ErsatzTV.Application.MediaCollections;
public record RemoveItemsFromCollection(int MediaCollectionId) : MediatR.IRequest<Either<BaseError, Unit>>
public record RemoveItemsFromCollection(int MediaCollectionId) : IRequest<Either<BaseError, Unit>>
{
public List<int> MediaItemIds { get; set; } = new();
}

2
ErsatzTV.Application/MediaCollections/Commands/RemoveItemsFromCollectionHandler.cs

@ -32,7 +32,7 @@ public class RemoveItemsFromCollectionHandler : IRequestHandler<RemoveItemsFromC @@ -32,7 +32,7 @@ public class RemoveItemsFromCollectionHandler : IRequestHandler<RemoveItemsFromC
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, Collection> validation = await Validate(dbContext, request);
return await validation.Apply(c => ApplyRemoveItemsRequest(dbContext, request, c));
return await LanguageExtensions.Apply(validation, c => ApplyRemoveItemsRequest(dbContext, request, c));
}
private async Task<Unit> ApplyRemoveItemsRequest(

6
ErsatzTV.Application/MediaCollections/Commands/TraktCommandBase.cs

@ -13,9 +13,9 @@ namespace ErsatzTV.Application.MediaCollections; @@ -13,9 +13,9 @@ namespace ErsatzTV.Application.MediaCollections;
public abstract class TraktCommandBase
{
private readonly ISearchRepository _searchRepository;
private readonly ISearchIndex _searchIndex;
private readonly ILogger _logger;
private readonly ISearchIndex _searchIndex;
private readonly ISearchRepository _searchRepository;
protected TraktCommandBase(
ITraktApiClient traktApiClient,
@ -189,7 +189,7 @@ public abstract class TraktCommandBase @@ -189,7 +189,7 @@ public abstract class TraktCommandBase
Title = item.Title,
Year = item.Year,
Season = item.Season,
Episode = item.Episode,
Episode = item.Episode
};
result.Guids = item.Guids.Map(g => new TraktListItemGuid { Guid = g, TraktListItem = result }).ToList();

2
ErsatzTV.Application/MediaCollections/Commands/UpdateCollection.cs

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
namespace ErsatzTV.Application.MediaCollections;
public record UpdateCollection
(int CollectionId, string Name) : MediatR.IRequest<Either<BaseError, Unit>>
(int CollectionId, string Name) : IRequest<Either<BaseError, Unit>>
{
public Option<bool> UseCustomPlaybackOrder { get; set; } = None;
}

2
ErsatzTV.Application/MediaCollections/Commands/UpdateCollectionCustomOrder.cs

@ -5,6 +5,6 @@ namespace ErsatzTV.Application.MediaCollections; @@ -5,6 +5,6 @@ namespace ErsatzTV.Application.MediaCollections;
public record UpdateCollectionCustomOrder
(
int CollectionId,
List<MediaItemCustomOrder> MediaItemCustomOrders) : MediatR.IRequest<Either<BaseError, Unit>>;
List<MediaItemCustomOrder> MediaItemCustomOrders) : IRequest<Either<BaseError, Unit>>;
public record MediaItemCustomOrder(int MediaItemId, int CustomIndex);

2
ErsatzTV.Application/MediaCollections/Commands/UpdateCollectionCustomOrderHandler.cs

@ -32,7 +32,7 @@ public class UpdateCollectionCustomOrderHandler : IRequestHandler<UpdateCollecti @@ -32,7 +32,7 @@ public class UpdateCollectionCustomOrderHandler : IRequestHandler<UpdateCollecti
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, Collection> validation = await Validate(dbContext, request);
return await validation.Apply(c => ApplyUpdateRequest(dbContext, c, request));
return await LanguageExtensions.Apply(validation, c => ApplyUpdateRequest(dbContext, c, request));
}
private async Task<Unit> ApplyUpdateRequest(

2
ErsatzTV.Application/MediaCollections/Commands/UpdateCollectionHandler.cs

@ -32,7 +32,7 @@ public class UpdateCollectionHandler : IRequestHandler<UpdateCollection, Either< @@ -32,7 +32,7 @@ public class UpdateCollectionHandler : IRequestHandler<UpdateCollection, Either<
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, Collection> validation = await Validate(dbContext, request);
return await validation.Apply(c => ApplyUpdateRequest(dbContext, c, request));
return await LanguageExtensions.Apply(validation, c => ApplyUpdateRequest(dbContext, c, request));
}
private async Task<Unit> ApplyUpdateRequest(TvContext dbContext, Collection c, UpdateCollection request)

8
ErsatzTV.Application/MediaCollections/Commands/UpdateMultiCollection.cs

@ -3,10 +3,14 @@ using ErsatzTV.Core.Domain; @@ -3,10 +3,14 @@ using ErsatzTV.Core.Domain;
namespace ErsatzTV.Application.MediaCollections;
public record UpdateMultiCollectionItem(int? CollectionId, int? SmartCollectionId, bool ScheduleAsGroup, PlaybackOrder PlaybackOrder);
public record UpdateMultiCollectionItem(
int? CollectionId,
int? SmartCollectionId,
bool ScheduleAsGroup,
PlaybackOrder PlaybackOrder);
public record UpdateMultiCollection
(
int MultiCollectionId,
string Name,
List<UpdateMultiCollectionItem> Items) : MediatR.IRequest<Either<BaseError, Unit>>;
List<UpdateMultiCollectionItem> Items) : IRequest<Either<BaseError, Unit>>;

2
ErsatzTV.Application/MediaCollections/Commands/UpdateMultiCollectionHandler.cs

@ -32,7 +32,7 @@ public class UpdateMultiCollectionHandler : IRequestHandler<UpdateMultiCollectio @@ -32,7 +32,7 @@ public class UpdateMultiCollectionHandler : IRequestHandler<UpdateMultiCollectio
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, MultiCollection> validation = await Validate(dbContext, request);
return await validation.Apply(c => ApplyUpdateRequest(dbContext, c, request));
return await LanguageExtensions.Apply(validation, c => ApplyUpdateRequest(dbContext, c, request));
}
private async Task<Unit> ApplyUpdateRequest(TvContext dbContext, MultiCollection c, UpdateMultiCollection request)

2
ErsatzTV.Application/MediaCollections/Commands/UpdateSmartCollectionHandler.cs

@ -32,7 +32,7 @@ public class UpdateSmartCollectionHandler : IRequestHandler<UpdateSmartCollectio @@ -32,7 +32,7 @@ public class UpdateSmartCollectionHandler : IRequestHandler<UpdateSmartCollectio
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, SmartCollection> validation = await Validate(dbContext, request);
return await validation.Apply(c => ApplyUpdateRequest(dbContext, c, request));
return await LanguageExtensions.Apply(validation, c => ApplyUpdateRequest(dbContext, c, request));
}
private async Task<Unit> ApplyUpdateRequest(TvContext dbContext, SmartCollection c, UpdateSmartCollection request)

3
ErsatzTV.Application/MediaCollections/Mapper.cs

@ -33,7 +33,8 @@ internal static class Mapper @@ -33,7 +33,8 @@ internal static class Mapper
multiCollectionItem.ScheduleAsGroup,
multiCollectionItem.PlaybackOrder);
private static MultiCollectionSmartItemViewModel ProjectToViewModel(MultiCollectionSmartItem multiCollectionSmartItem) =>
private static MultiCollectionSmartItemViewModel ProjectToViewModel(
MultiCollectionSmartItem multiCollectionSmartItem) =>
new(
multiCollectionSmartItem.MultiCollectionId,
ProjectToViewModel(multiCollectionSmartItem.SmartCollection),

4
ErsatzTV.Application/MediaCollections/Queries/GetPagedCollectionsHandler.cs

@ -9,10 +9,8 @@ public class GetPagedCollectionsHandler : IRequestHandler<GetPagedCollections, P @@ -9,10 +9,8 @@ public class GetPagedCollectionsHandler : IRequestHandler<GetPagedCollections, P
{
private readonly IDbContextFactory<TvContext> _dbContextFactory;
public GetPagedCollectionsHandler(IDbContextFactory<TvContext> dbContextFactory)
{
public GetPagedCollectionsHandler(IDbContextFactory<TvContext> dbContextFactory) =>
_dbContextFactory = dbContextFactory;
}
public async Task<PagedMediaCollectionsViewModel> Handle(
GetPagedCollections request,

4
ErsatzTV.Application/MediaCollections/Queries/GetPagedMultiCollectionsHandler.cs

@ -9,10 +9,8 @@ public class GetPagedMultiCollectionsHandler : IRequestHandler<GetPagedMultiColl @@ -9,10 +9,8 @@ public class GetPagedMultiCollectionsHandler : IRequestHandler<GetPagedMultiColl
{
private readonly IDbContextFactory<TvContext> _dbContextFactory;
public GetPagedMultiCollectionsHandler(IDbContextFactory<TvContext> dbContextFactory)
{
public GetPagedMultiCollectionsHandler(IDbContextFactory<TvContext> dbContextFactory) =>
_dbContextFactory = dbContextFactory;
}
public async Task<PagedMultiCollectionsViewModel> Handle(
GetPagedMultiCollections request,

4
ErsatzTV.Application/MediaCollections/Queries/GetPagedSmartCollectionsHandler.cs

@ -9,10 +9,8 @@ public class GetPagedSmartCollectionsHandler : IRequestHandler<GetPagedSmartColl @@ -9,10 +9,8 @@ public class GetPagedSmartCollectionsHandler : IRequestHandler<GetPagedSmartColl
{
private readonly IDbContextFactory<TvContext> _dbContextFactory;
public GetPagedSmartCollectionsHandler(IDbContextFactory<TvContext> dbContextFactory)
{
public GetPagedSmartCollectionsHandler(IDbContextFactory<TvContext> dbContextFactory) =>
_dbContextFactory = dbContextFactory;
}
public async Task<PagedSmartCollectionsViewModel> Handle(
GetPagedSmartCollections request,

4
ErsatzTV.Application/MediaCollections/Queries/GetPagedTraktListsHandler.cs

@ -9,10 +9,8 @@ public class GetPagedTraktListsHandler : IRequestHandler<GetPagedTraktLists, Pag @@ -9,10 +9,8 @@ public class GetPagedTraktListsHandler : IRequestHandler<GetPagedTraktLists, Pag
{
private readonly IDbContextFactory<TvContext> _dbContextFactory;
public GetPagedTraktListsHandler(IDbContextFactory<TvContext> dbContextFactory)
{
public GetPagedTraktListsHandler(IDbContextFactory<TvContext> dbContextFactory) =>
_dbContextFactory = dbContextFactory;
}
public async Task<PagedTraktListsViewModel> Handle(
GetPagedTraktLists request,

4
ErsatzTV.Application/MediaSources/Commands/ScanLocalLibraryHandler.cs

@ -74,8 +74,8 @@ public class ScanLocalLibraryHandler : IRequestHandler<ForceScanLocalLibrary, Ei @@ -74,8 +74,8 @@ public class ScanLocalLibraryHandler : IRequestHandler<ForceScanLocalLibrary, Ei
{
LibraryPath libraryPath = localLibrary.Paths[i];
decimal progressMin = (decimal) i / localLibrary.Paths.Count;
decimal progressMax = (decimal) (i + 1) / localLibrary.Paths.Count;
decimal progressMin = (decimal)i / localLibrary.Paths.Count;
decimal progressMax = (decimal)(i + 1) / localLibrary.Paths.Count;
var lastScan = new DateTimeOffset(libraryPath.LastScan ?? SystemTime.MinValueUtc, TimeSpan.Zero);
DateTimeOffset nextScan = lastScan + TimeSpan.FromHours(libraryRefreshInterval);

2
ErsatzTV.Application/Movies/Queries/GetMovieByIdHandler.cs

@ -9,8 +9,8 @@ namespace ErsatzTV.Application.Movies; @@ -9,8 +9,8 @@ namespace ErsatzTV.Application.Movies;
public class GetMovieByIdHandler : IRequestHandler<GetMovieById, Option<MovieViewModel>>
{
private readonly IMediaSourceRepository _mediaSourceRepository;
private readonly IDbContextFactory<TvContext> _dbContextFactory;
private readonly IMediaSourceRepository _mediaSourceRepository;
private readonly IMovieRepository _movieRepository;
public GetMovieByIdHandler(

6
ErsatzTV.Application/Playouts/Commands/BuildPlayoutHandler.cs

@ -15,9 +15,9 @@ public class BuildPlayoutHandler : IRequestHandler<BuildPlayout, Either<BaseErro @@ -15,9 +15,9 @@ public class BuildPlayoutHandler : IRequestHandler<BuildPlayout, Either<BaseErro
{
private readonly IClient _client;
private readonly IDbContextFactory<TvContext> _dbContextFactory;
private readonly IPlayoutBuilder _playoutBuilder;
private readonly IFFmpegSegmenterService _ffmpegSegmenterService;
private readonly ChannelWriter<ISubtitleWorkerRequest> _ffmpegWorkerChannel;
private readonly IPlayoutBuilder _playoutBuilder;
public BuildPlayoutHandler(
IClient client,
@ -37,7 +37,7 @@ public class BuildPlayoutHandler : IRequestHandler<BuildPlayout, Either<BaseErro @@ -37,7 +37,7 @@ public class BuildPlayoutHandler : IRequestHandler<BuildPlayout, Either<BaseErro
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, Playout> validation = await Validate(dbContext, request);
return await validation.Apply(playout => ApplyUpdateRequest(dbContext, request, playout));
return await LanguageExtensions.Apply(validation, playout => ApplyUpdateRequest(dbContext, request, playout));
}
private async Task<Unit> ApplyUpdateRequest(TvContext dbContext, BuildPlayout request, Playout playout)
@ -49,6 +49,7 @@ public class BuildPlayoutHandler : IRequestHandler<BuildPlayout, Either<BaseErro @@ -49,6 +49,7 @@ public class BuildPlayoutHandler : IRequestHandler<BuildPlayout, Either<BaseErro
{
_ffmpegSegmenterService.PlayoutUpdated(playout.Channel.Number);
}
await _ffmpegWorkerChannel.WriteAsync(new ExtractEmbeddedSubtitles(playout.Id));
}
catch (Exception ex)
@ -58,6 +59,7 @@ public class BuildPlayoutHandler : IRequestHandler<BuildPlayout, Either<BaseErro @@ -58,6 +59,7 @@ public class BuildPlayoutHandler : IRequestHandler<BuildPlayout, Either<BaseErro
return Unit.Default;
}
private static Task<Validation<BaseError, Playout>> Validate(TvContext dbContext, BuildPlayout request) =>
PlayoutMustExist(dbContext, request);

2
ErsatzTV.Application/Playouts/Commands/CreatePlayoutHandler.cs

@ -28,7 +28,7 @@ public class CreatePlayoutHandler : IRequestHandler<CreatePlayout, Either<BaseEr @@ -28,7 +28,7 @@ public class CreatePlayoutHandler : IRequestHandler<CreatePlayout, Either<BaseEr
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, Playout> validation = await Validate(dbContext, request);
return await validation.Apply(playout => PersistPlayout(dbContext, playout));
return await LanguageExtensions.Apply(validation, playout => PersistPlayout(dbContext, playout));
}
private async Task<CreatePlayoutResponse> PersistPlayout(TvContext dbContext, Playout playout)

15
ErsatzTV.Application/Playouts/Mapper.cs

@ -39,12 +39,18 @@ internal static class Mapper @@ -39,12 +39,18 @@ internal static class Mapper
.Map(am => $"{am.Title} - ").IfNone(string.Empty);
return mv.MusicVideoMetadata.HeadOrNone()
.Map(mvm => $"{artistName}{mvm.Title}")
.Map(s => string.IsNullOrWhiteSpace(playoutItem.ChapterTitle) ? s : $"{s} ({playoutItem.ChapterTitle})")
.Map(
s => string.IsNullOrWhiteSpace(playoutItem.ChapterTitle)
? s
: $"{s} ({playoutItem.ChapterTitle})")
.IfNone("[unknown music video]");
case OtherVideo ov:
return ov.OtherVideoMetadata.HeadOrNone()
.Map(ovm => ovm.Title ?? string.Empty)
.Map(s => string.IsNullOrWhiteSpace(playoutItem.ChapterTitle) ? s : $"{s} ({playoutItem.ChapterTitle})")
.Map(
s => string.IsNullOrWhiteSpace(playoutItem.ChapterTitle)
? s
: $"{s} ({playoutItem.ChapterTitle})")
.IfNone("[unknown video]");
case Song s:
string songArtist = s.SongMetadata.HeadOrNone()
@ -52,7 +58,10 @@ internal static class Mapper @@ -52,7 +58,10 @@ internal static class Mapper
.IfNone(string.Empty);
return s.SongMetadata.HeadOrNone()
.Map(sm => $"{songArtist}{sm.Title ?? string.Empty}")
.Map(t => string.IsNullOrWhiteSpace(playoutItem.ChapterTitle) ? t : $"{s} ({playoutItem.ChapterTitle})")
.Map(
t => string.IsNullOrWhiteSpace(playoutItem.ChapterTitle)
? t
: $"{s} ({playoutItem.ChapterTitle})")
.IfNone("[unknown song]");
default:
return string.Empty;

3
ErsatzTV.Application/Playouts/Queries/GetFuturePlayoutItemsById.cs

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
namespace ErsatzTV.Application.Playouts;
public record GetFuturePlayoutItemsById(int PlayoutId, bool ShowFiller, int PageNum, int PageSize) : IRequest<PagedPlayoutItemsViewModel>;
public record GetFuturePlayoutItemsById
(int PlayoutId, bool ShowFiller, int PageNum, int PageSize) : IRequest<PagedPlayoutItemsViewModel>;

5
ErsatzTV.Application/Playouts/Queries/GetFuturePlayoutItemsByIdHandler.cs

@ -22,7 +22,10 @@ public class GetFuturePlayoutItemsByIdHandler : IRequestHandler<GetFuturePlayout @@ -22,7 +22,10 @@ public class GetFuturePlayoutItemsByIdHandler : IRequestHandler<GetFuturePlayout
DateTime now = DateTimeOffset.Now.UtcDateTime;
int totalCount = await dbContext.PlayoutItems
.CountAsync(i => i.Finish >= now && i.PlayoutId == request.PlayoutId && (request.ShowFiller || i.FillerKind == FillerKind.None), cancellationToken);
.CountAsync(
i => i.Finish >= now && i.PlayoutId == request.PlayoutId &&
(request.ShowFiller || i.FillerKind == FillerKind.None),
cancellationToken);
List<PlayoutItemViewModel> page = await dbContext.PlayoutItems
.Include(i => i.MediaItem)

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save