Adds user settings management

Adds the UserSettings aggregate with pagination and alpha picker preferences, keyed to a user with a dedicated UserId foreign key. Adds GET and PUT /users/me/settings API endpoints, a localized Tools > Settings page with save confirmation, the EF migration for the UserSettings table, and unit, integration and security tests.
This commit is contained in:
BinaryAlley committed 2026-08-16 08:37:33 -07:00
1 parent c3f8786fe4
commit 2354e21d42
65 files changed
+4711 -21

No files matched your search

@@ -0,0 +1,25 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.UsersManagement.Settings.Commands.UpdateUserSettings;
using Lumina.Contracts.Requests.UsersManagement.Settings;
#endregion
namespace Lumina.Application.Common.Mapping.UsersManagement.Users;
/// <summary>
/// Extension methods for converting <see cref="UpdateUserSettingsRequest"/>.
/// </summary>
public static class UpdateUserSettingsRequestMapping
{
/// <summary>
/// Converts <paramref name="request"/> to <see cref="UpdateUserSettingsCommand"/>.
/// </summary>
/// <param name="request">The request to be converted.</param>
/// <returns>The converted command.</returns>
public static UpdateUserSettingsCommand ToCommand(this UpdateUserSettingsRequest request)
{
return new UpdateUserSettingsCommand(
request.IsPaginationEnabled,
request.ItemsPerPage,
request.IgnoreThePrefixForAlphaPicker);
}
}
@@ -0,0 +1,47 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Primitives;
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
using Lumina.Contracts.Responses.UsersManagement.Settings;
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserSettingsAggregate;
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserSettingsAggregate.ValueObjects;
#endregion
namespace Lumina.Application.Common.Mapping.UsersManagement.Users;
/// <summary>
/// Extension methods for converting <see cref="UserSettingsEntity"/>.
/// </summary>
public static class UserSettingsEntityMapping
{
/// <summary>
/// Converts <paramref name="repositoryEntity"/> to <see cref="UserSettings"/>.
/// </summary>
/// <param name="repositoryEntity">The repository entity to be converted.</param>
/// <returns>
/// An <see cref="Result{TValue}"/> containing either a successfully converted <see cref="UserSettings"/>, or an error message.
/// </returns>
public static Result<UserSettings> ToDomainEntity(this UserSettingsEntity repositoryEntity)
{
return UserSettings.Create(
UserSettingsId.Create(repositoryEntity.Id),
UserId.Create(repositoryEntity.UserId),
repositoryEntity.IsPaginationEnabled,
repositoryEntity.ItemsPerPage,
repositoryEntity.IgnoreThePrefixForAlphaPicker);
}
/// <summary>
/// Converts <paramref name="repositoryEntity"/> to <see cref="UserSettingsResponse"/>.
/// </summary>
/// <param name="repositoryEntity">The repository entity to be converted.</param>
/// <returns>The converted response.</returns>
public static UserSettingsResponse ToResponse(this UserSettingsEntity repositoryEntity)
{
return new UserSettingsResponse(
repositoryEntity.UserId,
repositoryEntity.IsPaginationEnabled,
repositoryEntity.ItemsPerPage,
repositoryEntity.IgnoreThePrefixForAlphaPicker);
}
}
@@ -0,0 +1,44 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
using Lumina.Contracts.Responses.UsersManagement.Settings;
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserSettingsAggregate;
#endregion
namespace Lumina.Application.Common.Mapping.UsersManagement.Users;
/// <summary>
/// Extension methods for converting <see cref="UserSettings"/>.
/// </summary>
public static class UserSettingsMapping
{
/// <summary>
/// Converts <paramref name="domainEntity"/> to <see cref="UserSettingsEntity"/>.
/// </summary>
/// <param name="domainEntity">The domain entity to be converted.</param>
/// <returns>The converted repository entity.</returns>
public static UserSettingsEntity ToRepositoryEntity(this UserSettings domainEntity)
{
return new UserSettingsEntity
{
Id = domainEntity.Id.Value,
UserId = domainEntity.UserId.Value,
IsPaginationEnabled = domainEntity.IsPaginationEnabled,
ItemsPerPage = domainEntity.ItemsPerPage,
IgnoreThePrefixForAlphaPicker = domainEntity.IgnoreThePrefixForAlphaPicker
};
}
/// <summary>
/// Converts <paramref name="domainEntity"/> to <see cref="UserSettingsResponse"/>.
/// </summary>
/// <param name="domainEntity">The domain entity to be converted.</param>
/// <returns>The converted response.</returns>
public static UserSettingsResponse ToResponse(this UserSettings domainEntity)
{
return new UserSettingsResponse(
domainEntity.UserId.Value,
domainEntity.IsPaginationEnabled,
domainEntity.ItemsPerPage,
domainEntity.IgnoreThePrefixForAlphaPicker);
}
}