diff --git a/src/Lumina.Application/Common/DTO/Filtering/LibraryFilterDto.cs b/src/Lumina.Application/Common/DTO/Filtering/LibraryFilterDto.cs
index d594dcc4..6b77d3dc 100644
--- a/src/Lumina.Application/Common/DTO/Filtering/LibraryFilterDto.cs
+++ b/src/Lumina.Application/Common/DTO/Filtering/LibraryFilterDto.cs
@@ -13,4 +13,17 @@ public record LibraryFilterDto : BaseFilterDto
/// The Id of the media library used to filter data.
///
public required Guid LibraryId { get; init; }
+
+ ///
+ /// The alpha key used to filter the data by the first character of the item title, for the alpha picker.
+ /// Can be to disable alpha filtering, a single ASCII letter (case-insensitive) to filter by that letter,
+ /// to filter by titles whose first character is a digit,
+ /// or to filter by titles whose first character is neither a letter nor a digit.
+ ///
+ public string? FilterAlphaKey { get; init; }
+
+ ///
+ /// Whether the leading "The " prefix of a title should be ignored when computing the alpha key, or not.
+ ///
+ public bool IgnoreThePrefixForAlphaPicker { get; init; }
}
diff --git a/src/Lumina.Application/Common/DTO/Filtering/LibraryItemAlphaKeys.cs b/src/Lumina.Application/Common/DTO/Filtering/LibraryItemAlphaKeys.cs
new file mode 100644
index 00000000..03693b53
--- /dev/null
+++ b/src/Lumina.Application/Common/DTO/Filtering/LibraryItemAlphaKeys.cs
@@ -0,0 +1,20 @@
+#region ========================================================================= USING =====================================================================================
+#endregion
+
+namespace Lumina.Application.Common.DTO.Filtering;
+
+///
+/// Collection of the special alpha keys that can be used for alpha filtering, in addition to the single letters.
+///
+public static class LibraryItemAlphaKeys
+{
+ ///
+ /// The alpha key that filters the items by titles whose first character is a digit.
+ ///
+ public const string NUMBER = "#";
+
+ ///
+ /// The alpha key that filters the items by titles whose first character is neither a letter nor a digit.
+ ///
+ public const string SYMBOL = "*";
+}
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksLiteRequestMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksLiteRequestMapping.cs
index 3e7a2c3e..c3fa2f9f 100644
--- a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksLiteRequestMapping.cs
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksLiteRequestMapping.cs
@@ -30,7 +30,9 @@ public static class GetBooksLiteRequestMapping
LibraryFilterDto libraryFilter = new()
{
LibraryId = request.LibraryId,
- SearchTerm = request.SearchTerm
+ SearchTerm = request.SearchTerm,
+ FilterAlphaKey = request.FilterAlphaKey,
+ IgnoreThePrefixForAlphaPicker = request.IgnoreThePrefixForAlphaPicker
};
return new GetBooksLiteQuery(paginationData, libraryFilter, request.SortBy, request.SortOrder);
diff --git a/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooksLite/GetBooksLiteQueryValidator.cs b/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooksLite/GetBooksLiteQueryValidator.cs
index 78cb8a79..6c8fb14b 100644
--- a/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooksLite/GetBooksLiteQueryValidator.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooksLite/GetBooksLiteQueryValidator.cs
@@ -1,4 +1,5 @@
#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DTO.Filtering;
using Lumina.Application.Common.Infrastructure.Validation;
using Lumina.Application.Common.Utilities;
using Lumina.Domain.Common.Errors;
@@ -22,5 +23,14 @@ public class GetBooksLiteQueryValidator : AbstractValidator
.WithError(Errors.Library.LibraryIdCannotBeEmpty)
.Must(id => id != Guid.Empty)
.WithError(Errors.Library.LibraryIdCannotBeEmpty);
+
+ // the alpha key must be exactly one of the three picker bucket kinds, so that the filter specification can
+ // derive the key of a title unambiguously: no filter, a number bucket, a symbol bucket, or a single ASCII letter
+ RuleFor(query => query.Filter.FilterAlphaKey)
+ .Must(alphaKey => alphaKey is null
+ || alphaKey == LibraryItemAlphaKeys.NUMBER
+ || alphaKey == LibraryItemAlphaKeys.SYMBOL
+ || (alphaKey.Length == 1 && char.IsAsciiLetter(alphaKey[0])))
+ .WithError(Errors.Library.InvalidFilterAlphaKey);
}
}
diff --git a/src/Lumina.Application/Lumina.Application.csproj b/src/Lumina.Application/Lumina.Application.csproj
index 3d18ba3c..d0c279a5 100644
--- a/src/Lumina.Application/Lumina.Application.csproj
+++ b/src/Lumina.Application/Lumina.Application.csproj
@@ -20,9 +20,9 @@
-
-
-
-
+
+
+
+
diff --git a/src/Lumina.Contracts/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksLiteRequest.cs b/src/Lumina.Contracts/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksLiteRequest.cs
index 4dbd3438..6a5a1dc1 100644
--- a/src/Lumina.Contracts/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksLiteRequest.cs
+++ b/src/Lumina.Contracts/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksLiteRequest.cs
@@ -13,6 +13,12 @@ namespace Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibra
/// The page of results to retrieve. Optional.
/// The maximum number of books to retrieve per page. Optional.
/// The search term used to filter results. Optional.
+///
+/// The alpha key used to filter the results by the first character of their title, for the alpha picker. Optional.
+/// Can be to disable alpha filtering, a single ASCII letter (case-insensitive) to filter by that letter,
+/// "#" to filter by titles whose first character is a digit, or "*" to filter by titles whose first character is neither a letter nor a digit.
+///
+/// Whether the leading "The " prefix of a title should be ignored when computing the alpha key, or not.
/// The name of the field by which to sort the results. Optional.
/// The direction in which to sort the results. Optional.
[DebuggerDisplay("LibraryId: {LibraryId}")]
@@ -21,6 +27,8 @@ public record GetBooksLiteRequest(
int? CurrentPage,
int? PerPage,
string? SearchTerm,
+ string? FilterAlphaKey,
+ bool IgnoreThePrefixForAlphaPicker,
string? SortBy,
SortOrder? SortOrder
);
diff --git a/src/Lumina.DataAccess/Core/Repositories/Books/BookRepository.cs b/src/Lumina.DataAccess/Core/Repositories/Books/BookRepository.cs
index 91e237c0..e2927044 100644
--- a/src/Lumina.DataAccess/Core/Repositories/Books/BookRepository.cs
+++ b/src/Lumina.DataAccess/Core/Repositories/Books/BookRepository.cs
@@ -15,6 +15,8 @@ using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Linq.Expressions;
+using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
#endregion
@@ -26,6 +28,10 @@ namespace Lumina.DataAccess.Core.Repositories.Books;
///
internal sealed class BookRepository : IBookRepository
{
+ private static readonly MethodInfo s_toLowerMethod = typeof(string).GetMethod(nameof(string.ToLower), Type.EmptyTypes)!;
+ private static readonly MethodInfo s_startsWithMethod = typeof(string).GetMethod(nameof(string.StartsWith), [typeof(string)])!;
+ private static readonly MethodInfo s_substringMethod = typeof(string).GetMethod(nameof(string.Substring), [typeof(int)])!;
+
private readonly LuminaDbContext _luminaDbContext;
///
@@ -120,13 +126,13 @@ internal sealed class BookRepository : IBookRepository
booksQuery = booksQuery.Where(book => book.LibraryId == libraryFilter.LibraryId);
- FilterSpecification? filterSpecification = BuildFilterSpecification(libraryFilter.SearchTerm);
+ FilterSpecification? filterSpecification = BuildFilterSpecification(libraryFilter);
// apply filtering
if (filterSpecification is not null)
booksQuery = booksQuery.Where(filterSpecification.ToExpression());
// apply sorting based on the specified sortBy and sortOrder parameters
- booksQuery = ApplySorting(booksQuery, sortBy, sortOrder ?? SortOrder.Ascending);
+ booksQuery = ApplySorting(booksQuery, sortBy, sortOrder ?? SortOrder.Ascending, libraryFilter.IgnoreThePrefixForAlphaPicker);
// if no pagination was requested, return all the books of the library
if (paginationData is null)
@@ -255,7 +261,8 @@ internal sealed class BookRepository : IBookRepository
/// The query to sort.
/// The field to sort by (case-insensitive).
/// The direction of the sorting.
- private static IOrderedQueryable ApplySorting(IQueryable booksQuery, string? sortBy, SortOrder sortOrder)
+ /// Whether a leading "the " prefix of a title is ignored when deriving the title sort key, or not.
+ private static IOrderedQueryable ApplySorting(IQueryable booksQuery, string? sortBy, SortOrder sortOrder, bool ignoreThePrefixForAlphaPicker)
{
return sortBy?.ToLower() switch
{
@@ -269,23 +276,67 @@ internal sealed class BookRepository : IBookRepository
? booksQuery.OrderByDescending(book => book.MetadataProvider)
: booksQuery.OrderBy(book => book.MetadataProvider),
_ => sortOrder == SortOrder.Descending
- ? booksQuery.OrderByDescending(book => book.Title)
- : booksQuery.OrderBy(book => book.Title),
+ ? booksQuery.OrderByDescending(BuildTitleSortKey(ignoreThePrefixForAlphaPicker))
+ : booksQuery.OrderBy(BuildTitleSortKey(ignoreThePrefixForAlphaPicker)),
};
}
+ ///
+ /// Builds the expression that derives the title sort key of a book, matching the effective title used by the alpha filter:
+ /// the title lowercased, falling back to the original title when the title is or empty, and optionally
+ /// stripped of a leading "the " prefix.
+ ///
+ /// Whether a leading "the " prefix of a title is ignored when deriving the title sort key, or not.
+ /// An expression that evaluates to the title sort key of a book.
+ private static Expression> BuildTitleSortKey(bool ignoreThePrefixForAlphaPicker)
+ {
+ ParameterExpression book = Expression.Parameter(typeof(BookEntity), "book");
+
+ Expression titleProperty = Expression.Property(book, nameof(BookEntity.Title));
+
+ // the raw title: the title, unless it is null or empty, in which case the original title (or an empty string) is used
+ BinaryExpression isTitleMissing = Expression.OrElse(
+ Expression.Equal(titleProperty, Expression.Constant(null, typeof(string))),
+ Expression.Equal(titleProperty, Expression.Constant(string.Empty)));
+ Expression rawTitle = Expression.Condition(isTitleMissing,
+ Expression.Coalesce(Expression.Property(book, nameof(BookEntity.OriginalTitle)), Expression.Constant(string.Empty)),
+ titleProperty);
+
+ MethodCallExpression lowerTitle = Expression.Call(rawTitle, s_toLowerMethod);
+
+ // when ignoring the "The " prefix, strip a leading "the " from the lowercased title
+ Expression effectiveTitle = lowerTitle;
+ if (ignoreThePrefixForAlphaPicker)
+ {
+ MethodCallExpression startsWithThe = Expression.Call(lowerTitle, s_startsWithMethod, Expression.Constant("the "));
+ MethodCallExpression strippedTitle = Expression.Call(lowerTitle, s_substringMethod, Expression.Constant(4));
+ effectiveTitle = Expression.Condition(startsWithThe, strippedTitle, lowerTitle);
+ }
+
+ return Expression.Lambda>(effectiveTitle, book);
+ }
+
///
/// Builds a filter specification for querying books.
///
- /// The search term used to filter results.
+ /// The model containing the parameters used to filter the results.
/// A filter specification that can be used to query books matching the provided criteria.
- private static FilterSpecification? BuildFilterSpecification(string? searchTerm)
+ private static FilterSpecification? BuildFilterSpecification(LibraryFilterDto libraryFilter)
{
FilterSpecification? filterSpecification = null;
-
- // include the search term filter here, if provided
- if (!string.IsNullOrWhiteSpace(searchTerm))
- filterSpecification = new BookSearchSpecification(searchTerm);
+
+ // include the search term filter, if provided
+ if (!string.IsNullOrWhiteSpace(libraryFilter.SearchTerm))
+ filterSpecification = new BookSearchSpecification(libraryFilter.SearchTerm);
+
+ // include the alpha key filter, if provided
+ if (libraryFilter.FilterAlphaKey is not null)
+ {
+ BookAlphaFilterSpecification alphaFilterSpecification = new(libraryFilter.FilterAlphaKey, libraryFilter.IgnoreThePrefixForAlphaPicker);
+ filterSpecification = filterSpecification is null
+ ? alphaFilterSpecification
+ : filterSpecification.And(alphaFilterSpecification);
+ }
return filterSpecification;
}
diff --git a/src/Lumina.DataAccess/Core/Repositories/Books/Specifications/BookAlphaFilterSpecification.cs b/src/Lumina.DataAccess/Core/Repositories/Books/Specifications/BookAlphaFilterSpecification.cs
new file mode 100644
index 00000000..460726ec
--- /dev/null
+++ b/src/Lumina.DataAccess/Core/Repositories/Books/Specifications/BookAlphaFilterSpecification.cs
@@ -0,0 +1,132 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
+using Lumina.Application.Common.DTO.Filtering;
+using Lumina.Application.Common.Specifications;
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Linq.Expressions;
+using System.Reflection;
+#endregion
+
+namespace Lumina.DataAccess.Core.Repositories.Books.Specifications;
+
+///
+/// Represents a filter specification for filtering books by the alpha key of their title, for the alpha picker.
+/// The alpha key is the first character of the title, lowercased, and optionally computed after ignoring a leading "The " prefix.
+///
+internal sealed class BookAlphaFilterSpecification : FilterSpecification
+{
+ private static readonly MethodInfo s_toLowerMethod = typeof(string).GetMethod(nameof(string.ToLower), Type.EmptyTypes)!;
+ private static readonly MethodInfo s_startsWithMethod = typeof(string).GetMethod(nameof(string.StartsWith), [typeof(string)])!;
+ private static readonly MethodInfo s_substringMethod = typeof(string).GetMethod(nameof(string.Substring), [typeof(int)])!;
+ private static readonly MethodInfo s_globMethod = typeof(SqliteDbFunctionsExtensions)
+ .GetMethod(nameof(SqliteDbFunctionsExtensions.Glob), [typeof(DbFunctions), typeof(string), typeof(string)])!;
+
+ private readonly string? _filterAlphaKey;
+ private readonly bool _ignoreThePrefixForAlphaPicker;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The alpha key to filter by. A single ASCII letter, , or .
+ /// Whether the leading "The " prefix of a title should be ignored when computing the alpha key, or not.
+ public BookAlphaFilterSpecification(string? filterAlphaKey, bool ignoreThePrefixForAlphaPicker)
+ {
+ _filterAlphaKey = filterAlphaKey;
+ _ignoreThePrefixForAlphaPicker = ignoreThePrefixForAlphaPicker;
+ }
+
+ ///
+ /// Creates a LINQ expression that represents the predicate defined by the current specification.
+ ///
+ /// An expression tree that can be used to evaluate whether a satisfies the specification criteria.
+ public override Expression> ToExpression()
+ {
+ // when no alpha key was requested, every book matches
+ if (_filterAlphaKey is null)
+ return book => true;
+
+ ParameterExpression book = Expression.Parameter(typeof(BookEntity), "book");
+ Expression effectiveTitle = BuildEffectiveTitle(book);
+
+ if (_filterAlphaKey == LibraryItemAlphaKeys.NUMBER)
+ return BuildGlobPredicate(book, effectiveTitle, "[0-9]*");
+
+ if (_filterAlphaKey == LibraryItemAlphaKeys.SYMBOL)
+ return BuildSymbolPredicate(book, effectiveTitle);
+
+ // the alpha key is a single ASCII letter
+ string globPattern = char.ToLowerInvariant(_filterAlphaKey[0]) + "*";
+ return BuildGlobPredicate(book, effectiveTitle, globPattern);
+ }
+
+ ///
+ /// Builds the expression representing the lowercased title used to derive the alpha key, falling back to the original title
+ /// when the title is or empty, and optionally stripped of a leading "the " prefix.
+ ///
+ /// The parameter representing the book entity.
+ /// The expression of the effective title.
+ private Expression BuildEffectiveTitle(ParameterExpression book)
+ {
+ Expression titleProperty = Expression.Property(book, nameof(BookEntity.Title));
+
+ // the raw title: the title, unless it is null or empty, in which case the original title (or an empty string) is used
+ BinaryExpression isTitleMissing = Expression.OrElse(
+ Expression.Equal(titleProperty, Expression.Constant(null, typeof(string))),
+ Expression.Equal(titleProperty, Expression.Constant(string.Empty)));
+ Expression rawTitle = Expression.Condition(isTitleMissing,
+ Expression.Coalesce(Expression.Property(book, nameof(BookEntity.OriginalTitle)), Expression.Constant(string.Empty)),
+ titleProperty);
+
+ MethodCallExpression lowerTitle = Expression.Call(rawTitle, s_toLowerMethod);
+
+ // when ignoring the "The " prefix, strip a leading "the " from the lowercased title
+ Expression effectiveTitle = lowerTitle;
+ if (_ignoreThePrefixForAlphaPicker)
+ {
+ MethodCallExpression startsWithThe = Expression.Call(lowerTitle, s_startsWithMethod, Expression.Constant("the "));
+ MethodCallExpression strippedTitle = Expression.Call(lowerTitle, s_substringMethod, Expression.Constant(4));
+ effectiveTitle = Expression.Condition(startsWithThe, strippedTitle, lowerTitle);
+ }
+
+ return effectiveTitle;
+ }
+
+ ///
+ /// Builds a predicate that is satisfied when the effective title starts with a glob pattern.
+ ///
+ /// The parameter representing the book entity.
+ /// The expression of the effective title.
+ /// The glob pattern the effective title must match.
+ /// The built predicate.
+ private static Expression> BuildGlobPredicate(ParameterExpression book, Expression effectiveTitle, string globPattern)
+ {
+ MethodCallExpression glob = BuildGlobCall(effectiveTitle, globPattern);
+ return Expression.Lambda>(glob, book);
+ }
+
+ ///
+ /// Builds a predicate that is satisfied when the first character of the effective title is neither a letter nor a digit.
+ ///
+ /// The parameter representing the book entity.
+ /// The expression of the effective title.
+ /// The built predicate.
+ private static Expression> BuildSymbolPredicate(ParameterExpression book, Expression effectiveTitle)
+ {
+ Expression notLetter = Expression.Not(BuildGlobCall(effectiveTitle, "[a-z]*"));
+ Expression notDigit = Expression.Not(BuildGlobCall(effectiveTitle, "[0-9]*"));
+ return Expression.Lambda>(Expression.AndAlso(notLetter, notDigit), book);
+ }
+
+ ///
+ /// Builds the call to for the effective title and the provided glob pattern.
+ ///
+ /// The expression of the effective title.
+ /// The glob pattern the effective title must match.
+ /// The built method call.
+ private static MethodCallExpression BuildGlobCall(Expression effectiveTitle, string globPattern)
+ {
+ Expression functions = Expression.Property(null, typeof(EF), nameof(EF.Functions));
+ return Expression.Call(s_globMethod, functions, effectiveTitle, Expression.Constant(globPattern));
+ }
+}
diff --git a/src/Lumina.DataAccess/Lumina.DataAccess.csproj b/src/Lumina.DataAccess/Lumina.DataAccess.csproj
index 307d4162..58cfd05e 100644
--- a/src/Lumina.DataAccess/Lumina.DataAccess.csproj
+++ b/src/Lumina.DataAccess/Lumina.DataAccess.csproj
@@ -18,15 +18,15 @@
-
-
-
-
+
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/src/Lumina.Domain/Common/Errors/Errors.Library.cs b/src/Lumina.Domain/Common/Errors/Errors.Library.cs
index 88aca409..906b5c69 100644
--- a/src/Lumina.Domain/Common/Errors/Errors.Library.cs
+++ b/src/Lumina.Domain/Common/Errors/Errors.Library.cs
@@ -15,6 +15,7 @@ public static partial class Errors
public static Error CannotScanDisabledLibrary => Error.Forbidden(description: nameof(CannotScanDisabledLibrary));
public static Error LibraryIdCannotBeEmpty => Error.Validation(description: nameof(LibraryIdCannotBeEmpty));
public static Error FilterMustIncludeLibraryId => Error.Validation(description: nameof(FilterMustIncludeLibraryId));
+ public static Error InvalidFilterAlphaKey => Error.Validation(description: nameof(InvalidFilterAlphaKey));
public static Error LibraryAlreadyExists => Error.Conflict(description: nameof(LibraryAlreadyExists));
public static Error LibraryNotFound => Error.NotFound(description: nameof(LibraryNotFound));
public static Error LibraryTypeCannotBeNull => Error.Validation(description: nameof(LibraryTypeCannotBeNull));
diff --git a/src/Lumina.Domain/Lumina.Domain.csproj b/src/Lumina.Domain/Lumina.Domain.csproj
index 7c45fad6..0f10cbfa 100644
--- a/src/Lumina.Domain/Lumina.Domain.csproj
+++ b/src/Lumina.Domain/Lumina.Domain.csproj
@@ -14,9 +14,9 @@
-
-
-
+
+
+
diff --git a/src/Lumina.Infrastructure/Lumina.Infrastructure.csproj b/src/Lumina.Infrastructure/Lumina.Infrastructure.csproj
index 13283b24..b6656eb3 100644
--- a/src/Lumina.Infrastructure/Lumina.Infrastructure.csproj
+++ b/src/Lumina.Infrastructure/Lumina.Infrastructure.csproj
@@ -17,18 +17,18 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Lumina.Plugins.Contracts/Lumina.Plugins.Contracts.csproj b/src/Lumina.Plugins.Contracts/Lumina.Plugins.Contracts.csproj
index c223d0c2..5cfe54a1 100644
--- a/src/Lumina.Plugins.Contracts/Lumina.Plugins.Contracts.csproj
+++ b/src/Lumina.Plugins.Contracts/Lumina.Plugins.Contracts.csproj
@@ -14,7 +14,7 @@
-
+
diff --git a/src/Lumina.Presentation.Api/Lumina.Presentation.Api.csproj b/src/Lumina.Presentation.Api/Lumina.Presentation.Api.csproj
index a1a29f78..df8c7e6b 100644
--- a/src/Lumina.Presentation.Api/Lumina.Presentation.Api.csproj
+++ b/src/Lumina.Presentation.Api/Lumina.Presentation.Api.csproj
@@ -22,22 +22,22 @@
-
-
-
-
-
-
+
+
+
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
+
+
+
-
-
-
+
+
+
diff --git a/src/Lumina.Presentation.Web/Common/Enums/Common/SortOrder.cs b/src/Lumina.Presentation.Web/Common/Enums/Common/SortOrder.cs
new file mode 100644
index 00000000..91482437
--- /dev/null
+++ b/src/Lumina.Presentation.Web/Common/Enums/Common/SortOrder.cs
@@ -0,0 +1,17 @@
+namespace Lumina.Presentation.Web.Common.Enums.Common;
+
+///
+/// Enumeration for the sort order.
+///
+public enum SortOrder
+{
+ ///
+ /// Ascending order.
+ ///
+ Ascending,
+
+ ///
+ /// Descending order.
+ ///
+ Descending
+}
diff --git a/src/Lumina.Presentation.Web/Common/Models/Libraries/BookLibraryItemsQueryModel.cs b/src/Lumina.Presentation.Web/Common/Models/Libraries/BookLibraryItemsQueryModel.cs
new file mode 100644
index 00000000..3cfe6f3e
--- /dev/null
+++ b/src/Lumina.Presentation.Web/Common/Models/Libraries/BookLibraryItemsQueryModel.cs
@@ -0,0 +1,56 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.Enums.Common;
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Presentation.Web.Common.Models.Libraries;
+
+///
+/// Represents the query parameters used to retrieve the lightweight details of the books of a media library.
+///
+[DebuggerDisplay("LibraryId: {LibraryId}")]
+public class BookLibraryItemsQueryModel
+{
+ ///
+ /// Gets or sets the Id of the media library whose books are retrieved.
+ ///
+ public Guid LibraryId { get; set; }
+
+ ///
+ /// Gets or sets the page of results to retrieve.
+ ///
+ public int? CurrentPage { get; set; }
+
+ ///
+ /// Gets or sets the maximum number of books to retrieve per page.
+ ///
+ public int? PerPage { get; set; }
+
+ ///
+ /// Gets or sets the search term used to filter results.
+ ///
+ public string? SearchTerm { get; set; }
+
+ ///
+ /// Gets or sets the alpha key used to filter the results by the first character of their title, for the alpha picker.
+ /// Can be to disable alpha filtering, a single ASCII letter (case-insensitive) to filter by that letter,
+ /// "#" to filter by titles whose first character is a digit, or "*" to filter by titles whose first character is neither a letter nor a digit.
+ ///
+ public string? FilterAlphaKey { get; set; }
+
+ ///
+ /// Gets or sets whether the leading "The " prefix of a title is ignored when computing the alpha key, or not.
+ ///
+ public bool IgnoreThePrefixForAlphaPicker { get; set; }
+
+ ///
+ /// Gets or sets the name of the field by which to sort the results.
+ ///
+ public string? SortBy { get; set; }
+
+ ///
+ /// Gets or sets the direction in which to sort the results.
+ ///
+ public SortOrder? SortOrder { get; set; }
+}
diff --git a/src/Lumina.Presentation.Web/Common/Models/Libraries/BookLiteModel.cs b/src/Lumina.Presentation.Web/Common/Models/Libraries/BookLiteModel.cs
new file mode 100644
index 00000000..ee124a74
--- /dev/null
+++ b/src/Lumina.Presentation.Web/Common/Models/Libraries/BookLiteModel.cs
@@ -0,0 +1,33 @@
+#region ========================================================================= USING =====================================================================================
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Presentation.Web.Common.Models.Libraries;
+
+///
+/// Represents a lightweight book element, containing only the properties needed by the client for card-style navigation.
+///
+[DebuggerDisplay("Title: {Title}")]
+public class BookLiteModel
+{
+ ///
+ /// Gets or sets the Id of the book.
+ ///
+ public Guid Id { get; set; }
+
+ ///
+ /// Gets or sets the title of the book.
+ ///
+ public string Title { get; set; } = string.Empty;
+
+ ///
+ /// Gets or sets the release year of the book (re-release year, if available, or original release year), if known.
+ ///
+ public int? ReleaseYear { get; set; }
+
+ ///
+ /// Gets or sets the path of the image representing the cover of the book, if available.
+ ///
+ public string? CoverPath { get; set; }
+}
diff --git a/src/Lumina.Presentation.Web/Common/Models/Libraries/PaginatedBookLiteModel.cs b/src/Lumina.Presentation.Web/Common/Models/Libraries/PaginatedBookLiteModel.cs
new file mode 100644
index 00000000..daed24fd
--- /dev/null
+++ b/src/Lumina.Presentation.Web/Common/Models/Libraries/PaginatedBookLiteModel.cs
@@ -0,0 +1,38 @@
+#region ========================================================================= USING =====================================================================================
+using System.Collections.Generic;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Presentation.Web.Common.Models.Libraries;
+
+///
+/// Represents a paginated collection of lightweight book elements, together with pagination metadata.
+///
+[DebuggerDisplay("CurrentPage: {CurrentPage}; Count: {Count}")]
+public class PaginatedBookLiteModel
+{
+ ///
+ /// Gets or sets the collection of lightweight book elements associated with this instance.
+ ///
+ public IReadOnlyList Data { get; set; } = [];
+
+ ///
+ /// Gets or sets the current page number in a paginated collection.
+ ///
+ public int CurrentPage { get; set; }
+
+ ///
+ /// Gets or sets the number of items to include per page in paginated results.
+ ///
+ public int PerPage { get; set; }
+
+ ///
+ /// Gets or sets the total number of elements available in the paginated result set.
+ ///
+ public int Count { get; set; }
+
+ ///
+ /// Gets or sets the total number of pages based on elements available in the result set and per page.
+ ///
+ public int NumberOfPages { get; set; }
+}
diff --git a/src/Lumina.Presentation.Web/Controllers/Library/WrittenContentLibrary/BookLibrary/BooksController.cs b/src/Lumina.Presentation.Web/Controllers/Library/WrittenContentLibrary/BookLibrary/BooksController.cs
index aab488d4..fa138956 100644
--- a/src/Lumina.Presentation.Web/Controllers/Library/WrittenContentLibrary/BookLibrary/BooksController.cs
+++ b/src/Lumina.Presentation.Web/Controllers/Library/WrittenContentLibrary/BookLibrary/BooksController.cs
@@ -1,22 +1,92 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.Api;
+using Lumina.Presentation.Web.Common.Models.Libraries;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
namespace Lumina.Presentation.Web.Controllers.Library.WrittenContentLibrary.BookLibrary;
+///
+/// Controller for books related operations.
+///
[Authorize]
-[Route("{culture}library/written-content-library/books-library/books")]
+[Route("{culture}/library/written-content-library/books-library/books")]
public class BooksController : Controller
{
- [HttpGet("")]
- public IActionResult Index()
+ private readonly IApiHttpClient _apiHttpClient;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected service for interactions with the API.
+ public BooksController(IApiHttpClient apiHttpClient)
{
- return View("/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.cshtml");
+ _apiHttpClient = apiHttpClient;
}
+ ///
+ /// Displays the view for browsing the books of a media library.
+ ///
+ /// The Id of the media library whose books are browsed.
+ /// Cancellation token that can be used to stop the execution.
+ [HttpGet("")]
+ public async Task Index(Guid? libraryId, CancellationToken cancellationToken = default)
+ {
+ if (libraryId is null)
+ return RedirectToAction("Index", "Home");
+
+ LibraryModel library = await _apiHttpClient.GetAsync($"libraries/{libraryId}", cancellationToken).ConfigureAwait(false);
+ return View("/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.cshtml", library);
+ }
+
+ ///
+ /// Gets the lightweight details of the books of a media library.
+ ///
+ /// The model containing the parameters used to retrieve the books.
+ /// Cancellation token that can be used to stop the execution.
+ [HttpGet("api-get-library-items")]
+ public async Task GetLibraryItems([FromQuery] BookLibraryItemsQueryModel query, CancellationToken cancellationToken = default)
+ {
+ PaginatedBookLiteModel response = await _apiHttpClient.GetAsync(BuildItemsEndpoint(query), cancellationToken).ConfigureAwait(false);
+ return Json(new { success = true, data = response });
+ }
+
+ ///
+ /// Displays the view for a single book.
+ ///
+ /// The Id of the book to display.
[HttpGet("{id}")]
public IActionResult EditBook(Guid id)
{
return View("/Views/Library/WrittenContentLibrary/BookLibrary/Books/Item.cshtml");
}
+
+ ///
+ /// Builds the API endpoint used to retrieve the lightweight details of the books of a media library, from the provided .
+ ///
+ /// The model containing the parameters used to retrieve the books.
+ /// The API endpoint to which the retrieval request is sent.
+ private static string BuildItemsEndpoint(BookLibraryItemsQueryModel query)
+ {
+ StringBuilder endpoint = new($"books/lite?libraryId={query.LibraryId}");
+ if (query.CurrentPage is not null)
+ endpoint.Append($"¤tPage={query.CurrentPage}");
+ if (query.PerPage is not null)
+ endpoint.Append($"&perPage={query.PerPage}");
+ if (!string.IsNullOrWhiteSpace(query.SearchTerm))
+ endpoint.Append($"&searchTerm={Uri.EscapeDataString(query.SearchTerm)}");
+ if (!string.IsNullOrWhiteSpace(query.FilterAlphaKey))
+ endpoint.Append($"&filterAlphaKey={Uri.EscapeDataString(query.FilterAlphaKey)}");
+ endpoint.Append($"&ignoreThePrefixForAlphaPicker={query.IgnoreThePrefixForAlphaPicker}");
+ if (!string.IsNullOrWhiteSpace(query.SortBy))
+ endpoint.Append($"&sortBy={Uri.EscapeDataString(query.SortBy)}");
+ if (query.SortOrder is not null)
+ endpoint.Append($"&sortOrder={query.SortOrder}");
+ return endpoint.ToString();
+ }
}
diff --git a/src/Lumina.Presentation.Web/Lumina.Presentation.Web.csproj b/src/Lumina.Presentation.Web/Lumina.Presentation.Web.csproj
index 1d093b6a..a29edcbc 100644
--- a/src/Lumina.Presentation.Web/Lumina.Presentation.Web.csproj
+++ b/src/Lumina.Presentation.Web/Lumina.Presentation.Web.csproj
@@ -19,17 +19,17 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.de-DE.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.de-DE.resx
new file mode 100644
index 00000000..e2208b8a
--- /dev/null
+++ b/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.de-DE.resx
@@ -0,0 +1,48 @@
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Suchen
+
+
+ Sortieren: A-Z
+
+
+ Sortieren: Z-A
+
+
+ Einträge
+
+
+ von
+
+
+ Seite
+
+
+ Zurück
+
+
+ Weiter
+
+
+ Alle
+
+
+ Diese Bibliothek hat keine Einträge
+
+
+ Keine Einträge entsprechen den aktuellen Filtern
+
+
diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.en-US.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.en-US.resx
new file mode 100644
index 00000000..f44c8d5a
--- /dev/null
+++ b/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.en-US.resx
@@ -0,0 +1,48 @@
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Search
+
+
+ Sort: A-Z
+
+
+ Sort: Z-A
+
+
+ items
+
+
+ of
+
+
+ Page
+
+
+ Previous
+
+
+ Next
+
+
+ All
+
+
+ This library has no items
+
+
+ No items match the current filters
+
+
diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.es-ES.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.es-ES.resx
new file mode 100644
index 00000000..ae88931b
--- /dev/null
+++ b/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.es-ES.resx
@@ -0,0 +1,48 @@
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Buscar
+
+
+ Ordenar: A-Z
+
+
+ Ordenar: Z-A
+
+
+ elementos
+
+
+ de
+
+
+ Página
+
+
+ Anterior
+
+
+ Siguiente
+
+
+ Todos
+
+
+ Esta biblioteca no tiene elementos
+
+
+ Ningún elemento coincide con los filtros actuales
+
+
diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.fr-FR.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.fr-FR.resx
new file mode 100644
index 00000000..5797b42e
--- /dev/null
+++ b/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.fr-FR.resx
@@ -0,0 +1,48 @@
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Rechercher
+
+
+ Trier : A-Z
+
+
+ Trier : Z-A
+
+
+ éléments
+
+
+ sur
+
+
+ Page
+
+
+ Précédent
+
+
+ Suivant
+
+
+ Tous
+
+
+ Cette bibliothèque ne contient aucun élément
+
+
+ Aucun élément ne correspond aux filtres actuels
+
+
diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.it-IT.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.it-IT.resx
new file mode 100644
index 00000000..78cd6fbe
--- /dev/null
+++ b/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.it-IT.resx
@@ -0,0 +1,48 @@
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Cerca
+
+
+ Ordina: A-Z
+
+
+ Ordina: Z-A
+
+
+ elementi
+
+
+ di
+
+
+ Pagina
+
+
+ Precedente
+
+
+ Successivo
+
+
+ Tutti
+
+
+ Questa biblioteca non contiene elementi
+
+
+ Nessun elemento corrisponde ai filtri correnti
+
+
diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.ja-JP.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.ja-JP.resx
new file mode 100644
index 00000000..2855a774
--- /dev/null
+++ b/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.ja-JP.resx
@@ -0,0 +1,48 @@
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 検索
+
+
+ 並べ替え: A-Z
+
+
+ 並べ替え: Z-A
+
+
+ 件
+
+
+ /
+
+
+ ページ
+
+
+ 前へ
+
+
+ 次へ
+
+
+ すべて
+
+
+ このライブラリには項目がありません
+
+
+ 現在のフィルターに一致する項目はありません
+
+
diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.resx
new file mode 100644
index 00000000..f44c8d5a
--- /dev/null
+++ b/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.resx
@@ -0,0 +1,48 @@
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Search
+
+
+ Sort: A-Z
+
+
+ Sort: Z-A
+
+
+ items
+
+
+ of
+
+
+ Page
+
+
+ Previous
+
+
+ Next
+
+
+ All
+
+
+ This library has no items
+
+
+ No items match the current filters
+
+
diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.ro-RO.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.ro-RO.resx
new file mode 100644
index 00000000..cec2e1d0
--- /dev/null
+++ b/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.ro-RO.resx
@@ -0,0 +1,48 @@
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Caută
+
+
+ Sortare: A-Z
+
+
+ Sortare: Z-A
+
+
+ elemente
+
+
+ din
+
+
+ Pagina
+
+
+ Înapoi
+
+
+ Înainte
+
+
+ Toate
+
+
+ Această bibliotecă nu are elemente
+
+
+ Niciun element nu corespunde filtrelor curente
+
+
diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.ru-RU.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.ru-RU.resx
new file mode 100644
index 00000000..a3c04101
--- /dev/null
+++ b/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.ru-RU.resx
@@ -0,0 +1,48 @@
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Поиск
+
+
+ Сортировка: А-Я
+
+
+ Сортировка: Я-А
+
+
+ элементов
+
+
+ из
+
+
+ Страница
+
+
+ Назад
+
+
+ Вперёд
+
+
+ Все
+
+
+ В этой библиотеке нет элементов
+
+
+ Ни один элемент не соответствует текущим фильтрам
+
+
diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.zh-CN.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.zh-CN.resx
new file mode 100644
index 00000000..d8e628ba
--- /dev/null
+++ b/src/Lumina.Presentation.Web/Resources/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.zh-CN.resx
@@ -0,0 +1,48 @@
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 搜索
+
+
+ 排序: A-Z
+
+
+ 排序: Z-A
+
+
+ 项
+
+
+ /
+
+
+ 页
+
+
+ 上一页
+
+
+ 下一页
+
+
+ 全部
+
+
+ 此库中没有项目
+
+
+ 没有项目符合当前筛选条件
+
+
diff --git a/src/Lumina.Presentation.Web/Views/Home/Index.cshtml b/src/Lumina.Presentation.Web/Views/Home/Index.cshtml
index d2b384d7..09a2baa7 100644
--- a/src/Lumina.Presentation.Web/Views/Home/Index.cshtml
+++ b/src/Lumina.Presentation.Web/Views/Home/Index.cshtml
@@ -27,11 +27,15 @@
+}
diff --git a/src/Lumina.Presentation.Web/wwwroot/css/site.css b/src/Lumina.Presentation.Web/wwwroot/css/site.css
index c1d39e58..a3df496f 100644
--- a/src/Lumina.Presentation.Web/wwwroot/css/site.css
+++ b/src/Lumina.Presentation.Web/wwwroot/css/site.css
@@ -1488,6 +1488,25 @@ th, td {
margin-left: auto !important;
}
+.alpha-picker {
+ display: flex;
+ flex-direction: column;
+ gap: 0.1rem;
+ overflow-y: auto;
+}
+
+.alpha-key {
+ padding: 0 0.6rem;
+ cursor: pointer;
+ text-align: center;
+ user-select: none;
+}
+
+ .alpha-key:hover,
+ .alpha-key.alpha-key-active {
+ background-color: #00000066;
+ }
+
/* For phones */
@media only screen and (max-width: 768px) {
main {
diff --git a/src/Lumina.Presentation.Web/wwwroot/images/ui/book-placeholder.svg b/src/Lumina.Presentation.Web/wwwroot/images/ui/book-placeholder.svg
new file mode 100644
index 00000000..4d3b03d1
--- /dev/null
+++ b/src/Lumina.Presentation.Web/wwwroot/images/ui/book-placeholder.svg
@@ -0,0 +1,8 @@
+
diff --git a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooksLite/GetBooksLiteQueryFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooksLite/GetBooksLiteQueryFixture.cs
index c23b0a8b..c7a7d0d9 100644
--- a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooksLite/GetBooksLiteQueryFixture.cs
+++ b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooksLite/GetBooksLiteQueryFixture.cs
@@ -26,6 +26,8 @@ public class GetBooksLiteQueryFixture
/// Optional. The Id of the media library whose books are retrieved.
/// Optional. The pagination data of the query.
/// Optional. The search term used to filter results.
+ /// Optional. The alpha key used to filter the results by the first character of their title, for the alpha picker.
+ /// Optional. Whether the leading "The " prefix of a title should be ignored when computing the alpha key, or not.
/// Optional. The name of the field by which to sort the results.
/// Optional. The direction in which to sort the results.
/// The created query to get the lightweight details of books.
@@ -33,6 +35,8 @@ public class GetBooksLiteQueryFixture
Guid? libraryId = null,
PaginationDataDto? paginationData = null,
string? searchTerm = null,
+ string? filterAlphaKey = null,
+ bool ignoreThePrefixForAlphaPicker = false,
string? sortBy = null,
SortOrder? sortOrder = null)
{
@@ -45,7 +49,9 @@ public class GetBooksLiteQueryFixture
new LibraryFilterDto
{
LibraryId = libraryId ?? _faker.Random.Guid(),
- SearchTerm = searchTerm
+ SearchTerm = searchTerm,
+ FilterAlphaKey = filterAlphaKey,
+ IgnoreThePrefixForAlphaPicker = ignoreThePrefixForAlphaPicker
},
sortBy,
sortOrder ?? _faker.PickRandom()
diff --git a/tests/Common/Lumina.Application.Fixtures/Lumina.Application.Fixtures.csproj b/tests/Common/Lumina.Application.Fixtures/Lumina.Application.Fixtures.csproj
index a6212580..66b5db27 100644
--- a/tests/Common/Lumina.Application.Fixtures/Lumina.Application.Fixtures.csproj
+++ b/tests/Common/Lumina.Application.Fixtures/Lumina.Application.Fixtures.csproj
@@ -15,7 +15,7 @@
-
+
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksLiteRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksLiteRequestFixture.cs
index 1d943636..ea878333 100644
--- a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksLiteRequestFixture.cs
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksLiteRequestFixture.cs
@@ -25,6 +25,8 @@ public class GetBooksLiteRequestFixture
/// Optional. The page of results to retrieve.
/// Optional. The maximum number of books to retrieve per page.
/// Optional. The search term used to filter results.
+ /// Optional. The alpha key used to filter the results by the first character of their title, for the alpha picker.
+ /// Optional. Whether the leading "The " prefix of a title should be ignored when computing the alpha key, or not.
/// Optional. The name of the field by which to sort the results.
/// Optional. The direction in which to sort the results.
/// The created .
@@ -33,6 +35,8 @@ public class GetBooksLiteRequestFixture
int? currentPage = null,
int? perPage = null,
string? searchTerm = null,
+ string? filterAlphaKey = null,
+ bool ignoreThePrefixForAlphaPicker = false,
string? sortBy = null,
SortOrder? sortOrder = null)
{
@@ -41,6 +45,8 @@ public class GetBooksLiteRequestFixture
CurrentPage: currentPage ?? _faker.Random.Number(1, 100),
PerPage: perPage ?? _faker.Random.Number(1, 200),
SearchTerm: searchTerm ?? _faker.Lorem.Word(),
+ FilterAlphaKey: filterAlphaKey,
+ IgnoreThePrefixForAlphaPicker: ignoreThePrefixForAlphaPicker,
SortBy: sortBy ?? _faker.Lorem.Word(),
SortOrder: sortOrder ?? _faker.PickRandom()
);
diff --git a/tests/Common/Lumina.Domain.Fixtures/Lumina.Domain.Fixtures.csproj b/tests/Common/Lumina.Domain.Fixtures/Lumina.Domain.Fixtures.csproj
index 36a8369e..eb6de35d 100644
--- a/tests/Common/Lumina.Domain.Fixtures/Lumina.Domain.Fixtures.csproj
+++ b/tests/Common/Lumina.Domain.Fixtures/Lumina.Domain.Fixtures.csproj
@@ -1,4 +1,4 @@
-
+
net10.0
@@ -15,7 +15,7 @@
-
+
diff --git a/tests/Common/Lumina.Domain.SharedKernel.Fixtures/Lumina.Domain.SharedKernel.Fixtures.csproj b/tests/Common/Lumina.Domain.SharedKernel.Fixtures/Lumina.Domain.SharedKernel.Fixtures.csproj
index 8df01af4..f90110b3 100644
--- a/tests/Common/Lumina.Domain.SharedKernel.Fixtures/Lumina.Domain.SharedKernel.Fixtures.csproj
+++ b/tests/Common/Lumina.Domain.SharedKernel.Fixtures/Lumina.Domain.SharedKernel.Fixtures.csproj
@@ -12,8 +12,8 @@
-
-
+
+
diff --git a/tests/Common/Lumina.Infrastructure.Fixtures/Lumina.Infrastructure.Fixtures.csproj b/tests/Common/Lumina.Infrastructure.Fixtures/Lumina.Infrastructure.Fixtures.csproj
index 2d72755b..d7f01314 100644
--- a/tests/Common/Lumina.Infrastructure.Fixtures/Lumina.Infrastructure.Fixtures.csproj
+++ b/tests/Common/Lumina.Infrastructure.Fixtures/Lumina.Infrastructure.Fixtures.csproj
@@ -15,7 +15,7 @@
-
+
diff --git a/tests/Common/Lumina.Presentation.Api.Fixtures/Lumina.Presentation.Api.Fixtures.csproj b/tests/Common/Lumina.Presentation.Api.Fixtures/Lumina.Presentation.Api.Fixtures.csproj
index fdecf674..708faffa 100644
--- a/tests/Common/Lumina.Presentation.Api.Fixtures/Lumina.Presentation.Api.Fixtures.csproj
+++ b/tests/Common/Lumina.Presentation.Api.Fixtures/Lumina.Presentation.Api.Fixtures.csproj
@@ -15,7 +15,7 @@
-
+
diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooksLite/GetBooksLiteEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooksLite/GetBooksLiteEndpointTests.cs
index 6b39fd29..9071aed8 100644
--- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooksLite/GetBooksLiteEndpointTests.cs
+++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooksLite/GetBooksLiteEndpointTests.cs
@@ -82,6 +82,121 @@ public class GetBooksLiteEndpointTests : IClassFixture book.Title == "Book B");
}
+ [Fact]
+ public async Task GetBooksLite_WhenCalledWithFilterAlphaKeyLetter_ShouldReturnOnlyBooksStartingWithThatLetter()
+ {
+ // Arrange
+ Guid userId = GetCurrentUserId();
+ Guid libraryId = Guid.NewGuid();
+ await SeedLibraryAsync(libraryId, userId);
+ await SeedBookAsync(libraryId, "Quiet Place");
+ await SeedBookAsync(libraryId, "The Quiet");
+ await SeedBookAsync(libraryId, "Racing");
+
+ // Act
+ HttpResponseMessage response = await _client.GetAsync($"/api/v1/books/lite?libraryId={libraryId}&filterAlphaKey=q");
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ PaginatedResponse? paginatedBooks = await response.Content.ReadFromJsonAsync>(_jsonOptions);
+ Assert.NotNull(paginatedBooks);
+ BookLiteResponse book = Assert.Single(paginatedBooks!.Data);
+ Assert.Equal("Quiet Place", book.Title);
+ Assert.Equal(1, paginatedBooks.Count);
+ }
+
+ [Fact]
+ public async Task GetBooksLite_WhenCalledWithFilterAlphaKeyLetterAndIgnoreThePrefix_ShouldIncludeThePrefixedTitles()
+ {
+ // Arrange
+ Guid userId = GetCurrentUserId();
+ Guid libraryId = Guid.NewGuid();
+ await SeedLibraryAsync(libraryId, userId);
+ await SeedBookAsync(libraryId, "Quiet Place");
+ await SeedBookAsync(libraryId, "The Quiet");
+ await SeedBookAsync(libraryId, "Racing");
+
+ // Act
+ HttpResponseMessage response = await _client.GetAsync($"/api/v1/books/lite?libraryId={libraryId}&filterAlphaKey=q&ignoreThePrefixForAlphaPicker=true");
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ PaginatedResponse? paginatedBooks = await response.Content.ReadFromJsonAsync>(_jsonOptions);
+ Assert.NotNull(paginatedBooks);
+ Assert.Equal(2, paginatedBooks!.Count);
+ Assert.Contains(paginatedBooks.Data, book => book.Title == "Quiet Place");
+ Assert.Contains(paginatedBooks.Data, book => book.Title == "The Quiet");
+ }
+
+ [Fact]
+ public async Task GetBooksLite_WhenCalledWithFilterAlphaKeyNumber_ShouldReturnOnlyBooksStartingWithADigit()
+ {
+ // Arrange
+ Guid userId = GetCurrentUserId();
+ Guid libraryId = Guid.NewGuid();
+ await SeedLibraryAsync(libraryId, userId);
+ await SeedBookAsync(libraryId, "1984");
+ await SeedBookAsync(libraryId, "7 Habits of Highly Effective People");
+ await SeedBookAsync(libraryId, "Brave New World");
+
+ // Act
+ HttpResponseMessage response = await _client.GetAsync($"/api/v1/books/lite?libraryId={libraryId}&filterAlphaKey=%23");
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ PaginatedResponse? paginatedBooks = await response.Content.ReadFromJsonAsync>(_jsonOptions);
+ Assert.NotNull(paginatedBooks);
+ Assert.Equal(2, paginatedBooks!.Count);
+ Assert.Contains(paginatedBooks.Data, book => book.Title == "1984");
+ Assert.Contains(paginatedBooks.Data, book => book.Title == "7 Habits of Highly Effective People");
+ }
+
+ [Fact]
+ public async Task GetBooksLite_WhenCalledWithFilterAlphaKeySymbol_ShouldReturnOnlyBooksStartingWithASymbol()
+ {
+ // Arrange
+ Guid userId = GetCurrentUserId();
+ Guid libraryId = Guid.NewGuid();
+ await SeedLibraryAsync(libraryId, userId);
+ await SeedBookAsync(libraryId, "!Important");
+ await SeedBookAsync(libraryId, "1984");
+ await SeedBookAsync(libraryId, "Alpha");
+
+ // Act
+ HttpResponseMessage response = await _client.GetAsync($"/api/v1/books/lite?libraryId={libraryId}&filterAlphaKey=%2A");
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ PaginatedResponse? paginatedBooks = await response.Content.ReadFromJsonAsync>(_jsonOptions);
+ Assert.NotNull(paginatedBooks);
+ BookLiteResponse book = Assert.Single(paginatedBooks!.Data);
+ Assert.Equal("!Important", book.Title);
+ Assert.Equal(1, paginatedBooks.Count);
+ }
+
+ [Fact]
+ public async Task GetBooksLite_WhenTitleIsEmptyAndFilterAlphaKeyIsProvided_ShouldUseOriginalTitle()
+ {
+ // Arrange
+ Guid userId = GetCurrentUserId();
+ Guid libraryId = Guid.NewGuid();
+ await SeedLibraryAsync(libraryId, userId);
+ await SeedBookAsync(libraryId, "", "Rendezvous");
+ await SeedBookAsync(libraryId, "Racing");
+ await SeedBookAsync(libraryId, "Quiet Place");
+
+ // Act
+ HttpResponseMessage response = await _client.GetAsync($"/api/v1/books/lite?libraryId={libraryId}&filterAlphaKey=r");
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ PaginatedResponse? paginatedBooks = await response.Content.ReadFromJsonAsync>(_jsonOptions);
+ Assert.NotNull(paginatedBooks);
+ Assert.Equal(2, paginatedBooks!.Count);
+ Assert.Contains(paginatedBooks.Data, book => book.Title == ""); // the empty title book matches the filter through its original title
+ Assert.Contains(paginatedBooks.Data, book => book.Title == "Racing");
+ }
+
[Fact]
public async Task GetBooksLite_WhenCalledWithSearchTerm_ShouldReturnOnlyMatchingBooks()
{
@@ -204,8 +319,9 @@ public class GetBooksLiteEndpointTests : IClassFixture
/// The Id of the media library the book belongs to.
/// The title of the book.
+ /// Optional. The original title of the book.
/// A task representing the asynchronous operation.
- private async Task SeedBookAsync(Guid libraryId, string title)
+ private async Task SeedBookAsync(Guid libraryId, string title, string? originalTitle = null)
{
using IServiceScope scope = _apiFactory.Services.CreateScope();
LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
@@ -215,6 +331,7 @@ public class GetBooksLiteEndpointTests : IClassFixture
-
-
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
+
+
+
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Lumina.Presentation.Api.SecurityTests.csproj b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Lumina.Presentation.Api.SecurityTests.csproj
index c9e24be6..0e12b100 100644
--- a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Lumina.Presentation.Api.SecurityTests.csproj
+++ b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Lumina.Presentation.Api.SecurityTests.csproj
@@ -19,17 +19,17 @@
-
-
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
+
+
+
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooksLite/GetBooksLiteQueryValidatorTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooksLite/GetBooksLiteQueryValidatorTests.cs
index 6055ca7d..8ce32ace 100644
--- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooksLite/GetBooksLiteQueryValidatorTests.cs
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooksLite/GetBooksLiteQueryValidatorTests.cs
@@ -46,4 +46,46 @@ public class GetBooksLiteQueryValidatorTests
// Assert
result.ShouldNotHaveAnyValidationErrors();
}
+
+ [Fact]
+ public void Validate_WhenFilterAlphaKeyIsNotASingleLetterOrSpecialKey_ShouldHaveValidationError()
+ {
+ // Arrange
+ GetBooksLiteQuery query = _getBooksLiteQueryFixture.Create();
+ query = query with { Filter = query.Filter with { FilterAlphaKey = "AB" } };
+
+ // Act
+ List result = _validator.TestValidate(query);
+
+ // Assert
+ result.ShouldHaveValidationError(Errors.Library.InvalidFilterAlphaKey);
+ }
+
+ [Fact]
+ public void Validate_WhenFilterAlphaKeyIsASingleLetter_ShouldNotHaveValidationError()
+ {
+ // Arrange
+ GetBooksLiteQuery query = _getBooksLiteQueryFixture.Create();
+ query = query with { Filter = query.Filter with { FilterAlphaKey = "Q" } };
+
+ // Act
+ List result = _validator.TestValidate(query);
+
+ // Assert
+ result.ShouldNotHaveAnyValidationErrors();
+ }
+
+ [Fact]
+ public void Validate_WhenFilterAlphaKeyIsNumberOrSymbol_ShouldNotHaveValidationError()
+ {
+ // Arrange
+ GetBooksLiteQuery query = _getBooksLiteQueryFixture.Create();
+ query = query with { Filter = query.Filter with { FilterAlphaKey = "#" } };
+
+ // Act
+ List result = _validator.TestValidate(query);
+
+ // Assert
+ result.ShouldNotHaveAnyValidationErrors();
+ }
}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Lumina.Application.UnitTests.csproj b/tests/UnitTests/Lumina.Application.UnitTests/Lumina.Application.UnitTests.csproj
index cd947fb9..19b106d5 100644
--- a/tests/UnitTests/Lumina.Application.UnitTests/Lumina.Application.UnitTests.csproj
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Lumina.Application.UnitTests.csproj
@@ -19,16 +19,16 @@
-
-
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
+
+
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/tests/UnitTests/Lumina.DataAccess.UnitTests/Lumina.DataAccess.UnitTests.csproj b/tests/UnitTests/Lumina.DataAccess.UnitTests/Lumina.DataAccess.UnitTests.csproj
index e8f0da90..3a52577b 100644
--- a/tests/UnitTests/Lumina.DataAccess.UnitTests/Lumina.DataAccess.UnitTests.csproj
+++ b/tests/UnitTests/Lumina.DataAccess.UnitTests/Lumina.DataAccess.UnitTests.csproj
@@ -19,18 +19,18 @@
-
-
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
-
+
+
+
+
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/tests/UnitTests/Lumina.Domain.UnitTests/Lumina.Domain.UnitTests.csproj b/tests/UnitTests/Lumina.Domain.UnitTests/Lumina.Domain.UnitTests.csproj
index d4b1d67c..2074eb90 100644
--- a/tests/UnitTests/Lumina.Domain.UnitTests/Lumina.Domain.UnitTests.csproj
+++ b/tests/UnitTests/Lumina.Domain.UnitTests/Lumina.Domain.UnitTests.csproj
@@ -18,18 +18,18 @@
-
+
-
-
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
+
+
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/tests/UnitTests/Lumina.Infrastructure.UnitTests/Lumina.Infrastructure.UnitTests.csproj b/tests/UnitTests/Lumina.Infrastructure.UnitTests/Lumina.Infrastructure.UnitTests.csproj
index 9daa4aa2..383df266 100644
--- a/tests/UnitTests/Lumina.Infrastructure.UnitTests/Lumina.Infrastructure.UnitTests.csproj
+++ b/tests/UnitTests/Lumina.Infrastructure.UnitTests/Lumina.Infrastructure.UnitTests.csproj
@@ -19,16 +19,16 @@
-
-
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
+
+
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Admin/Authorization/Permissions/GetPermissions/GetPermissionsEndpointTests.cs b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Admin/Authorization/Permissions/GetPermissions/GetPermissionsEndpointTests.cs
index e9a68cbe..8c6f3287 100644
--- a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Admin/Authorization/Permissions/GetPermissions/GetPermissionsEndpointTests.cs
+++ b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Admin/Authorization/Permissions/GetPermissions/GetPermissionsEndpointTests.cs
@@ -52,7 +52,7 @@ public class GetPermissionsEndpointTests
.Returns(Result.From(expectedResponse));
// Act
- IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
+ IResult result = await _sut.ExecuteAsync(EmptyRequest.Instance, cancellationToken);
// Assert
Ok> okResult = Assert.IsType>>(result);
@@ -69,7 +69,7 @@ public class GetPermissionsEndpointTests
.Returns(expectedError);
// Act
- IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
+ IResult result = await _sut.ExecuteAsync(EmptyRequest.Instance, cancellationToken);
// Assert
ProblemHttpResult problemResult = Assert.IsType(result);
@@ -94,7 +94,7 @@ public class GetPermissionsEndpointTests
.Returns(Result.From(response));
// Act
- await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
+ await _sut.ExecuteAsync(EmptyRequest.Instance, cancellationToken);
// Assert
await _mockHandler.Received(1).HandleAsync(
@@ -120,7 +120,7 @@ public class GetPermissionsEndpointTests
}, info.Arg()));
// Act
- Task operationTask = _sut.ExecuteAsync(new EmptyRequest(), cts.Token);
+ Task operationTask = _sut.ExecuteAsync(EmptyRequest.Instance, cts.Token);
await operationStarted.Task;
cts.Cancel();
cancellationRequested.SetResult(true);
diff --git a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Admin/Authorization/Roles/GetRoles/GetRolesEndpointTests.cs b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Admin/Authorization/Roles/GetRoles/GetRolesEndpointTests.cs
index 895adfd5..5cf487fa 100644
--- a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Admin/Authorization/Roles/GetRoles/GetRolesEndpointTests.cs
+++ b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Admin/Authorization/Roles/GetRoles/GetRolesEndpointTests.cs
@@ -48,7 +48,7 @@ public class GetRolesEndpointTests
.Returns(Result.From(expectedResponse));
// Act
- IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
+ IResult result = await _sut.ExecuteAsync(EmptyRequest.Instance, cancellationToken);
// Assert
Ok> okResult = Assert.IsType>>(result);
@@ -65,7 +65,7 @@ public class GetRolesEndpointTests
.Returns(expectedError);
// Act
- IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
+ IResult result = await _sut.ExecuteAsync(EmptyRequest.Instance, cancellationToken);
// Assert
ProblemHttpResult problemResult = Assert.IsType(result);
@@ -92,7 +92,7 @@ public class GetRolesEndpointTests
} as IEnumerable));
// Act
- await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
+ await _sut.ExecuteAsync(EmptyRequest.Instance, cancellationToken);
// Assert
await _mockHandler.Received(1).HandleAsync(
@@ -118,7 +118,7 @@ public class GetRolesEndpointTests
}, info.Arg()));
// Act
- Task operationTask = _sut.ExecuteAsync(new EmptyRequest(), cts.Token);
+ Task operationTask = _sut.ExecuteAsync(EmptyRequest.Instance, cts.Token);
await operationStarted.Task;
cts.Cancel();
cancellationRequested.SetResult(true);
diff --git a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Drives/GetDrivesEndpointTests.cs b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Drives/GetDrivesEndpointTests.cs
index 61619e12..4a0cbc97 100644
--- a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Drives/GetDrivesEndpointTests.cs
+++ b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Drives/GetDrivesEndpointTests.cs
@@ -48,7 +48,7 @@ public class GetDrivesEndpointTests
.Returns(Result.From(expectedResponses.AsEnumerable()));
// Act
- IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
+ IResult result = await _sut.ExecuteAsync(EmptyRequest.Instance, cancellationToken);
// Assert
Ok> okResult = Assert.IsType>>(result);
@@ -65,7 +65,7 @@ public class GetDrivesEndpointTests
.Returns(expectedError);
// Act
- IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
+ IResult result = await _sut.ExecuteAsync(EmptyRequest.Instance, cancellationToken);
// Assert
ProblemHttpResult problemDetails = Assert.IsType(result);
@@ -89,7 +89,7 @@ public class GetDrivesEndpointTests
.Returns(Result.From(Enumerable.Empty()));
// Act
- await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
+ await _sut.ExecuteAsync(EmptyRequest.Instance, cancellationToken);
// Assert
await _mockHandler.Received(1).HandleAsync(Arg.Any(), Arg.Is(cancellationToken));
@@ -113,7 +113,7 @@ public class GetDrivesEndpointTests
}, callInfo.Arg()));
// Act
- Task operationTask = _sut.ExecuteAsync(new EmptyRequest(), cts.Token);
+ Task operationTask = _sut.ExecuteAsync(EmptyRequest.Instance, cts.Token);
await operationStarted.Task;
cts.Cancel();
cancellationRequested.SetResult(true);
diff --git a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/FileSystem/GetTypeEndpointTests.cs b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/FileSystem/GetTypeEndpointTests.cs
index e2bfe3cd..d6c06761 100644
--- a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/FileSystem/GetTypeEndpointTests.cs
+++ b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/FileSystem/GetTypeEndpointTests.cs
@@ -44,7 +44,7 @@ public class GetTypeEndpointTests
.Returns(expectedResponse);
// Act
- IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
+ IResult result = await _sut.ExecuteAsync(EmptyRequest.Instance, cancellationToken);
// Assert
Ok okResult = Assert.IsType>(result);
@@ -63,7 +63,7 @@ public class GetTypeEndpointTests
.Returns(expectedResponse);
// Act
- IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
+ IResult result = await _sut.ExecuteAsync(EmptyRequest.Instance, cancellationToken);
// Assert
Ok okResult = Assert.IsType>(result);
@@ -79,7 +79,7 @@ public class GetTypeEndpointTests
.Returns(new FileSystemTypeResponse(PlatformType.Windows));
// Act
- await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
+ await _sut.ExecuteAsync(EmptyRequest.Instance, cancellationToken);
// Assert
await _mockHandler.Received(1).HandleAsync(Arg.Any(), Arg.Is(cancellationToken));
@@ -103,7 +103,7 @@ public class GetTypeEndpointTests
}, callInfo.Arg()));
// Act
- Task operationTask = _sut.ExecuteAsync(new EmptyRequest(), cts.Token);
+ Task operationTask = _sut.ExecuteAsync(EmptyRequest.Instance, cts.Token);
await operationStarted.Task;
cts.Cancel();
cancellationRequested.SetResult(true);
diff --git a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Maintenance/ApplicationSetup/CheckInitializationEndpointTests.cs b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Maintenance/ApplicationSetup/CheckInitializationEndpointTests.cs
index 53e94a62..362c8e7d 100644
--- a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Maintenance/ApplicationSetup/CheckInitializationEndpointTests.cs
+++ b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Maintenance/ApplicationSetup/CheckInitializationEndpointTests.cs
@@ -43,7 +43,7 @@ public class CheckInitializationEndpointTests
.Returns(expectedResponse);
// Act
- IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
+ IResult result = await _sut.ExecuteAsync(EmptyRequest.Instance, cancellationToken);
// Assert
Ok okResult = Assert.IsType>(result);
@@ -59,7 +59,7 @@ public class CheckInitializationEndpointTests
.Returns(new InitializationResponse(IsInitialized: true));
// Act
- await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
+ await _sut.ExecuteAsync(EmptyRequest.Instance, cancellationToken);
// Assert
await _mockHandler.Received(1).HandleAsync(
@@ -85,7 +85,7 @@ public class CheckInitializationEndpointTests
}, callInfo.Arg()));
// Act
- Task operationTask = _sut.ExecuteAsync(new EmptyRequest(), cts.Token);
+ Task operationTask = _sut.ExecuteAsync(EmptyRequest.Instance, cts.Token);
await operationStarted.Task;
cts.Cancel();
cancellationRequested.SetResult(true);
diff --git a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/UsersManagement/Authentication/GetUsers/GetUsersEndpointTests.cs b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/UsersManagement/Authentication/GetUsers/GetUsersEndpointTests.cs
index 132e33d9..8f156ec0 100644
--- a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/UsersManagement/Authentication/GetUsers/GetUsersEndpointTests.cs
+++ b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/UsersManagement/Authentication/GetUsers/GetUsersEndpointTests.cs
@@ -47,7 +47,7 @@ public class GetUsersEndpointTests
.Returns(Result.From(expectedResponse));
// Act
- IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
+ IResult result = await _sut.ExecuteAsync(EmptyRequest.Instance, cancellationToken);
// Assert
Ok> okResult = Assert.IsType>>(result);
@@ -64,7 +64,7 @@ public class GetUsersEndpointTests
.Returns(expectedError);
// Act
- IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
+ IResult result = await _sut.ExecuteAsync(EmptyRequest.Instance, cancellationToken);
// Assert
ProblemHttpResult problemResult = Assert.IsType(result);
@@ -88,7 +88,7 @@ public class GetUsersEndpointTests
.Returns(Result.From(Array.Empty() as IEnumerable));
// Act
- await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
+ await _sut.ExecuteAsync(EmptyRequest.Instance, cancellationToken);
// Assert
await _mockHandler.Received(1).HandleAsync(
@@ -114,7 +114,7 @@ public class GetUsersEndpointTests
}, info.Arg()));
// Act
- Task operationTask = _sut.ExecuteAsync(new EmptyRequest(), cts.Token);
+ Task operationTask = _sut.ExecuteAsync(EmptyRequest.Instance, cts.Token);
await operationStarted.Task;
cts.Cancel();
cancellationRequested.SetResult(true);
diff --git a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/UsersManagement/Settings/GetUserSettings/GetUserSettingsEndpointTests.cs b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/UsersManagement/Settings/GetUserSettings/GetUserSettingsEndpointTests.cs
index 580fedb9..122bb46c 100644
--- a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/UsersManagement/Settings/GetUserSettings/GetUserSettingsEndpointTests.cs
+++ b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/UsersManagement/Settings/GetUserSettings/GetUserSettingsEndpointTests.cs
@@ -44,7 +44,7 @@ public class GetUserSettingsEndpointTests
.Returns(Result.From(expectedResponse));
// Act
- IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
+ IResult result = await _sut.ExecuteAsync(EmptyRequest.Instance, cancellationToken);
// Assert
Ok okResult = Assert.IsType>(result);
@@ -61,7 +61,7 @@ public class GetUserSettingsEndpointTests
.Returns(expectedError);
// Act
- IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
+ IResult result = await _sut.ExecuteAsync(EmptyRequest.Instance, cancellationToken);
// Assert
ProblemHttpResult problemResult = Assert.IsType(result);
@@ -82,7 +82,7 @@ public class GetUserSettingsEndpointTests
.Returns(Result.From(new UserSettingsResponse(Guid.NewGuid(), true, 48, false)));
// Act
- await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
+ await _sut.ExecuteAsync(EmptyRequest.Instance, cancellationToken);
// Assert
await _mockHandler.Received(1).HandleAsync(
@@ -108,7 +108,7 @@ public class GetUserSettingsEndpointTests
}, info.Arg()));
// Act
- Task operationTask = _sut.ExecuteAsync(new EmptyRequest(), cts.Token);
+ Task operationTask = _sut.ExecuteAsync(EmptyRequest.Instance, cts.Token);
await operationStarted.Task;
cts.Cancel();
cancellationRequested.SetResult(true);
diff --git a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Lumina.Presentation.Api.UnitTests.csproj b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Lumina.Presentation.Api.UnitTests.csproj
index a16f6132..e084c9c2 100644
--- a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Lumina.Presentation.Api.UnitTests.csproj
+++ b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Lumina.Presentation.Api.UnitTests.csproj
@@ -19,17 +19,17 @@
-
-
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
+
+
+
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive