mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 10:11:10 +00:00
Merge branch 'feature/add-metadata-aggregation' into feature/add-artwork-provider-and-metadata-aggregation
This commit is contained in:
commit
b47588cf83
168 files changed
+3503
-1062
No files matched your search
+30
-13
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
#endregion
|
||||
@@ -38,23 +37,41 @@ internal class FileSystemStructureSeedService : IFileSystemStructureSeedService
|
||||
if (rootPathIdResult.IsFailure)
|
||||
return rootPathIdResult.Errors;
|
||||
|
||||
// create the libraries directory
|
||||
Result<string> librariesPathResult = _pathService.CombinePath(rootPath, "libraries");
|
||||
if (librariesPathResult.IsFailure)
|
||||
return librariesPathResult.Errors;
|
||||
Result<Created> createLibrariesDirectoryResult = EnsureDirectory(rootPathIdResult.Value, "libraries");
|
||||
if (createLibrariesDirectoryResult.IsFailure)
|
||||
return createLibrariesDirectoryResult.Errors;
|
||||
|
||||
Result<FileSystemPathId> libraryPathIdResult = FileSystemPathId.Create(librariesPathResult.Value);
|
||||
if (libraryPathIdResult.IsFailure)
|
||||
return libraryPathIdResult.Errors;
|
||||
Result<Created> createBooksDirectoryResult = EnsureDirectory(rootPathIdResult.Value, "books");
|
||||
if (createBooksDirectoryResult.IsFailure)
|
||||
return createBooksDirectoryResult.Errors;
|
||||
|
||||
Result<bool> librariesDirectoryExistsResult = _environmentContext.DirectoryProviderService.DirectoryExists(libraryPathIdResult.Value);
|
||||
if (librariesDirectoryExistsResult.IsFailure)
|
||||
return librariesDirectoryExistsResult.Errors;
|
||||
return Result.Created;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the directory with the provided <paramref name="directoryName"/> under the <paramref name="rootPathId"/>, when it does not already exist.
|
||||
/// </summary>
|
||||
/// <param name="rootPathId">The id of the root path under which the directory is created.</param>
|
||||
/// <param name="directoryName">The name of the directory to create.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
private Result<Created> EnsureDirectory(FileSystemPathId rootPathId, string directoryName)
|
||||
{
|
||||
Result<string> directoryPathResult = _pathService.CombinePath(rootPathId.Path, directoryName);
|
||||
if (directoryPathResult.IsFailure)
|
||||
return directoryPathResult.Errors;
|
||||
|
||||
Result<FileSystemPathId> directoryPathIdResult = FileSystemPathId.Create(directoryPathResult.Value);
|
||||
if (directoryPathIdResult.IsFailure)
|
||||
return directoryPathIdResult.Errors;
|
||||
|
||||
Result<bool> directoryExistsResult = _environmentContext.DirectoryProviderService.DirectoryExists(directoryPathIdResult.Value);
|
||||
if (directoryExistsResult.IsFailure)
|
||||
return directoryExistsResult.Errors;
|
||||
|
||||
// only create it if it doesn't already exist
|
||||
if (!librariesDirectoryExistsResult.Value)
|
||||
if (!directoryExistsResult.Value)
|
||||
{
|
||||
Result<FileSystemPathId> createDirectoryResult = _environmentContext.DirectoryProviderService.CreateDirectory(rootPathIdResult.Value, "libraries");
|
||||
Result<FileSystemPathId> createDirectoryResult = _environmentContext.DirectoryProviderService.CreateDirectory(rootPathId, directoryName);
|
||||
if (createDirectoryResult.IsFailure)
|
||||
return createDirectoryResult.Errors;
|
||||
}
|
||||
|
||||
+10
-10
@@ -63,7 +63,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
/// <summary>
|
||||
/// Gets whether this media library should update the metadata of its elements from the web, or not.
|
||||
/// </summary>
|
||||
public bool DownloadMetadataFromWeb { get; private set; } = true;
|
||||
public bool CanDownloadMetadataFromWeb { get; private set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether this media library should copy the downloaded metadata into the media library content locations, or not.
|
||||
@@ -97,7 +97,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
/// <param name="coverImage">The path of the image file used as the cover for the library.</param>
|
||||
/// <param name="isEnabled">Whether this media library is enabled or not. A disabled media library is never shown or changed.</param>
|
||||
/// <param name="isLocked">Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated.</param>
|
||||
/// <param name="downloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether this media library should copy the downloaded metadata into the media library content locations, or not.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.</param>
|
||||
/// <param name="scanIds">The list of objects representing the unique identifier of scans of the media library.</param>
|
||||
@@ -110,7 +110,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
string? coverImage,
|
||||
bool isEnabled,
|
||||
bool isLocked,
|
||||
bool downloadMetadataFromWeb,
|
||||
bool canDownloadMetadataFromWeb,
|
||||
bool shouldSaveMetadataInMediaDirectories,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan,
|
||||
List<ScanId> scanIds) : base(id)
|
||||
@@ -122,7 +122,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
CoverImage = coverImage;
|
||||
IsEnabled = isEnabled;
|
||||
IsLocked = isLocked;
|
||||
DownloadMetadataFromWeb = downloadMetadataFromWeb;
|
||||
CanDownloadMetadataFromWeb = canDownloadMetadataFromWeb;
|
||||
ShouldSaveMetadataInMediaDirectories = shouldSaveMetadataInMediaDirectories;
|
||||
ShouldSkipUnchangedDirectoriesDuringScan = shouldSkipUnchangedDirectoriesDuringScan;
|
||||
_scanIds = scanIds;
|
||||
@@ -138,7 +138,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
/// <param name="coverImageSourcePath">The path of the image file chosen by the user to be used as the cover for the library.</param>
|
||||
/// <param name="isEnabled">Whether this media library is enabled or not. A disabled media library is never shown or changed.</param>
|
||||
/// <param name="isLocked">Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated.</param>
|
||||
/// <param name="downloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether this media library should copy the downloaded metadata into the media library content locations, or not.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.</param>
|
||||
/// <param name="scanIds">The list of objects representing the unique identifier of scans of the media library.</param>
|
||||
@@ -153,7 +153,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
string? coverImageSourcePath,
|
||||
bool isEnabled,
|
||||
bool isLocked,
|
||||
bool downloadMetadataFromWeb,
|
||||
bool canDownloadMetadataFromWeb,
|
||||
bool shouldSaveMetadataInMediaDirectories,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan,
|
||||
List<ScanId> scanIds)
|
||||
@@ -176,7 +176,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
coverImageSourcePath,
|
||||
isEnabled,
|
||||
isLocked,
|
||||
downloadMetadataFromWeb,
|
||||
canDownloadMetadataFromWeb,
|
||||
shouldSaveMetadataInMediaDirectories,
|
||||
shouldSkipUnchangedDirectoriesDuringScan,
|
||||
scanIds
|
||||
@@ -194,7 +194,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
/// <param name="coverImageSourcePath">The path of the image file chosen by the user to be used as the cover for the library.</param>
|
||||
/// <param name="isEnabled">Whether this media library is enabled or not. A disabled media library is never shown or changed.</param>
|
||||
/// <param name="isLocked">Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated.</param>
|
||||
/// <param name="downloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether this media library should copy the downloaded metadata into the media library content locations, or not.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.</param>
|
||||
/// <param name="scanIds">The list of objects representing the unique identifier of scans of the media library.</param>
|
||||
@@ -210,7 +210,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
string? coverImageSourcePath,
|
||||
bool isEnabled,
|
||||
bool isLocked,
|
||||
bool downloadMetadataFromWeb,
|
||||
bool canDownloadMetadataFromWeb,
|
||||
bool shouldSaveMetadataInMediaDirectories,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan,
|
||||
List<ScanId> scanIds)
|
||||
@@ -233,7 +233,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
coverImageSourcePath,
|
||||
isEnabled,
|
||||
isLocked,
|
||||
downloadMetadataFromWeb,
|
||||
canDownloadMetadataFromWeb,
|
||||
shouldSaveMetadataInMediaDirectories,
|
||||
shouldSkipUnchangedDirectoriesDuringScan,
|
||||
scanIds
|
||||
|
||||
+1
-2
@@ -17,10 +17,9 @@ public interface IMediaLibraryScanningService
|
||||
/// </summary>
|
||||
/// <param name="scan">The media library scan to start.</param>
|
||||
/// <param name="libraryType">The type of the media library to be scanned.</param>
|
||||
/// <param name="downloadMetadataFromWeb">Whether the library permits downloading data from the web, or not.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
Task<Result<Success>> StartScanAsync(LibraryScan scan, LibraryType libraryType, bool downloadMetadataFromWeb, CancellationToken cancellationToken);
|
||||
Task<Result<Success>> StartScanAsync(LibraryScan scan, LibraryType libraryType, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Cancels <paramref name="scan"/>.
|
||||
|
||||
+4
-5
@@ -1,7 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using Lumina.Domain.Common.Events;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Cancellation;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Progress;
|
||||
@@ -9,6 +8,7 @@ using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.Library
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Scanners;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
@@ -55,10 +55,9 @@ internal class MediaLibraryScanningService : IMediaLibraryScanningService
|
||||
/// </summary>
|
||||
/// <param name="scan">The media library scan to start.</param>
|
||||
/// <param name="libraryType">The type of the media library to be scanned.</param>
|
||||
/// <param name="downloadMetadataFromWeb">Whether the library permits downloading data from the web, or not.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
public async Task<Result<Success>> StartScanAsync(LibraryScan scan, LibraryType libraryType, bool downloadMetadataFromWeb, CancellationToken cancellationToken)
|
||||
public async Task<Result<Success>> StartScanAsync(LibraryScan scan, LibraryType libraryType, CancellationToken cancellationToken)
|
||||
{
|
||||
// mark the scan itself as started
|
||||
Result<Success> startScanResult = scan.StartScan();
|
||||
@@ -81,7 +80,7 @@ internal class MediaLibraryScanningService : IMediaLibraryScanningService
|
||||
IMediaTypeScanner scanner = _mediaLibraryScannerFactory.CreateLibraryScanner(libraryType);
|
||||
// get the list of scan jobs for the retrieved scanner. It is impotant to enumerate them here, because deferred execuction would destroy any graph relationships
|
||||
// and properties we might set before putting the jobs on the in-memory queue.
|
||||
List<IMediaLibraryScanJob> jobs = [.. scanner.CreateScanJobsForLibrary(scan.LibraryId, downloadMetadataFromWeb)];
|
||||
List<IMediaLibraryScanJob> jobs = [.. scanner.CreateScanJobsForLibrary(scan.LibraryId)];
|
||||
|
||||
// count total jobs in the chain by traversing the job graph
|
||||
int totalJobs = CountTotalJobs(jobs);
|
||||
|
||||
+1
-2
@@ -21,7 +21,6 @@ public interface IMediaTypeScanner
|
||||
/// Creates the media library scan jobs for the provided media library.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">The unique identifier of the media library for which to create the media library scan jobs.</param>
|
||||
/// <param name="downloadMetadataFromWeb">Whether the library permits downloading data from the web, or not.</param>
|
||||
/// <returns>A collection of media library scan jobs.</returns>
|
||||
IEnumerable<IMediaLibraryScanJob> CreateScanJobsForLibrary(LibraryId libraryId, bool downloadMetadataFromWeb);
|
||||
IEnumerable<IMediaLibraryScanJob> CreateScanJobsForLibrary(LibraryId libraryId);
|
||||
}
|
||||
+37
-21
@@ -4,7 +4,6 @@ using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserSettingsAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
@@ -20,6 +19,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
private const int DEFAULT_ITEMS_PER_PAGE = 48;
|
||||
private const bool DEFAULT_IGNORE_THE_PREFIX_FOR_ALPHA_PICKER = false;
|
||||
private const bool DEFAULT_IS_THEME_CACHING_ENABLED = true;
|
||||
private const bool DEFAULT_AGGREGATE_METADATA_WHEN_MISSING = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the object representing the unique identifier of the user that owns these settings.
|
||||
@@ -39,13 +39,18 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
/// <summary>
|
||||
/// Gets whether the "The" prefix of library item titles is ignored by the alpha picker, or not.
|
||||
/// </summary>
|
||||
public bool IgnoreThePrefixForAlphaPicker { get; private set; }
|
||||
public bool ShouldIgnoreThePrefixForAlphaPicker { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the theme data served to this user is cached, or not.
|
||||
/// </summary>
|
||||
public bool IsThemeCachingEnabled { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.
|
||||
/// </summary>
|
||||
public bool ShouldAggregateMetadataWhenMissing { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UserSettings"/> class.
|
||||
/// </summary>
|
||||
@@ -53,21 +58,24 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
/// <param name="userId">The object representing the unique identifier of the user that owns these settings.</param>
|
||||
/// <param name="isPaginationEnabled">Whether pagination is enabled for the user, or not.</param>
|
||||
/// <param name="itemsPerPage">The number of library items displayed per page when pagination is enabled.</param>
|
||||
/// <param name="ignoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
||||
/// <param name="isThemeCachingEnabled">Whether the theme data served to this user is cached, or not.</param>
|
||||
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
|
||||
private UserSettings(
|
||||
UserSettingsId id,
|
||||
UserId userId,
|
||||
bool isPaginationEnabled,
|
||||
int itemsPerPage,
|
||||
bool ignoreThePrefixForAlphaPicker,
|
||||
bool isThemeCachingEnabled) : base(id)
|
||||
bool shouldIgnoreThePrefixForAlphaPicker,
|
||||
bool isThemeCachingEnabled,
|
||||
bool shouldAggregateMetadataWhenMissing) : base(id)
|
||||
{
|
||||
UserId = userId;
|
||||
IsPaginationEnabled = isPaginationEnabled;
|
||||
ItemsPerPage = itemsPerPage;
|
||||
IgnoreThePrefixForAlphaPicker = ignoreThePrefixForAlphaPicker;
|
||||
ShouldIgnoreThePrefixForAlphaPicker = shouldIgnoreThePrefixForAlphaPicker;
|
||||
IsThemeCachingEnabled = isThemeCachingEnabled;
|
||||
ShouldAggregateMetadataWhenMissing = shouldAggregateMetadataWhenMissing;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -78,7 +86,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
/// </returns>
|
||||
public static Result<UserSettings> Create()
|
||||
{
|
||||
return Create(UserId.CreateUnique(), DEFAULT_IS_PAGINATION_ENABLED, DEFAULT_ITEMS_PER_PAGE, DEFAULT_IGNORE_THE_PREFIX_FOR_ALPHA_PICKER, DEFAULT_IS_THEME_CACHING_ENABLED);
|
||||
return Create(UserId.CreateUnique(), DEFAULT_IS_PAGINATION_ENABLED, DEFAULT_ITEMS_PER_PAGE, DEFAULT_IGNORE_THE_PREFIX_FOR_ALPHA_PICKER, DEFAULT_IS_THEME_CACHING_ENABLED, DEFAULT_AGGREGATE_METADATA_WHEN_MISSING);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -90,7 +98,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
/// </returns>
|
||||
public static Result<UserSettings> Create(UserId userId)
|
||||
{
|
||||
return Create(userId, DEFAULT_IS_PAGINATION_ENABLED, DEFAULT_ITEMS_PER_PAGE, DEFAULT_IGNORE_THE_PREFIX_FOR_ALPHA_PICKER, DEFAULT_IS_THEME_CACHING_ENABLED);
|
||||
return Create(userId, DEFAULT_IS_PAGINATION_ENABLED, DEFAULT_ITEMS_PER_PAGE, DEFAULT_IGNORE_THE_PREFIX_FOR_ALPHA_PICKER, DEFAULT_IS_THEME_CACHING_ENABLED, DEFAULT_AGGREGATE_METADATA_WHEN_MISSING);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -99,8 +107,9 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
/// <param name="userId">The object representing the unique identifier of the user that owns these settings.</param>
|
||||
/// <param name="isPaginationEnabled">Whether pagination is enabled for the user, or not.</param>
|
||||
/// <param name="itemsPerPage">The number of library items displayed per page when pagination is enabled.</param>
|
||||
/// <param name="ignoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
||||
/// <param name="isThemeCachingEnabled">Whether the theme data served to this user is cached, or not.</param>
|
||||
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="UserSettings"/>, or an error message.
|
||||
/// </returns>
|
||||
@@ -108,8 +117,9 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
UserId userId,
|
||||
bool isPaginationEnabled,
|
||||
int itemsPerPage,
|
||||
bool ignoreThePrefixForAlphaPicker,
|
||||
bool isThemeCachingEnabled)
|
||||
bool shouldIgnoreThePrefixForAlphaPicker,
|
||||
bool isThemeCachingEnabled,
|
||||
bool shouldAggregateMetadataWhenMissing)
|
||||
{
|
||||
if (itemsPerPage <= 0)
|
||||
return Errors.UserSettings.ItemsPerPageMustBeGreaterThanZero;
|
||||
@@ -119,8 +129,9 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
userId,
|
||||
isPaginationEnabled,
|
||||
itemsPerPage,
|
||||
ignoreThePrefixForAlphaPicker,
|
||||
isThemeCachingEnabled);
|
||||
shouldIgnoreThePrefixForAlphaPicker,
|
||||
isThemeCachingEnabled,
|
||||
shouldAggregateMetadataWhenMissing);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -130,8 +141,9 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
/// <param name="userId">The object representing the unique identifier of the user that owns these settings.</param>
|
||||
/// <param name="isPaginationEnabled">Whether pagination is enabled for the user, or not.</param>
|
||||
/// <param name="itemsPerPage">The number of library items displayed per page when pagination is enabled.</param>
|
||||
/// <param name="ignoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
||||
/// <param name="isThemeCachingEnabled">Whether the theme data served to this user is cached, or not.</param>
|
||||
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="UserSettings"/>, or an error message.
|
||||
/// </returns>
|
||||
@@ -140,13 +152,14 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
UserId userId,
|
||||
bool isPaginationEnabled,
|
||||
int itemsPerPage,
|
||||
bool ignoreThePrefixForAlphaPicker,
|
||||
bool isThemeCachingEnabled)
|
||||
bool shouldIgnoreThePrefixForAlphaPicker,
|
||||
bool isThemeCachingEnabled,
|
||||
bool shouldAggregateMetadataWhenMissing)
|
||||
{
|
||||
if (itemsPerPage <= 0)
|
||||
return Errors.UserSettings.ItemsPerPageMustBeGreaterThanZero;
|
||||
|
||||
return new UserSettings(id, userId, isPaginationEnabled, itemsPerPage, ignoreThePrefixForAlphaPicker, isThemeCachingEnabled);
|
||||
return new UserSettings(id, userId, isPaginationEnabled, itemsPerPage, shouldIgnoreThePrefixForAlphaPicker, isThemeCachingEnabled, shouldAggregateMetadataWhenMissing);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -154,22 +167,25 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
/// </summary>
|
||||
/// <param name="isPaginationEnabled">Whether pagination is enabled for the user, or not.</param>
|
||||
/// <param name="itemsPerPage">The number of library items displayed per page when pagination is enabled.</param>
|
||||
/// <param name="ignoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
||||
/// <param name="isThemeCachingEnabled">Whether the theme data served to this user is cached, or not.</param>
|
||||
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful update, or an error.</returns>
|
||||
public Result<Updated> UpdateSettings(
|
||||
bool isPaginationEnabled,
|
||||
int itemsPerPage,
|
||||
bool ignoreThePrefixForAlphaPicker,
|
||||
bool isThemeCachingEnabled)
|
||||
bool shouldIgnoreThePrefixForAlphaPicker,
|
||||
bool isThemeCachingEnabled,
|
||||
bool shouldAggregateMetadataWhenMissing)
|
||||
{
|
||||
if (itemsPerPage <= 0)
|
||||
return Errors.UserSettings.ItemsPerPageMustBeGreaterThanZero;
|
||||
|
||||
IsPaginationEnabled = isPaginationEnabled;
|
||||
ItemsPerPage = itemsPerPage;
|
||||
IgnoreThePrefixForAlphaPicker = ignoreThePrefixForAlphaPicker;
|
||||
ShouldIgnoreThePrefixForAlphaPicker = shouldIgnoreThePrefixForAlphaPicker;
|
||||
IsThemeCachingEnabled = isThemeCachingEnabled;
|
||||
ShouldAggregateMetadataWhenMissing = shouldAggregateMetadataWhenMissing;
|
||||
return Result.Updated;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user