mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 17:11:10 +00:00
Stores scheduler page display preferences per user
This commit is contained in:
1 parent
ab8ab51397
commit
237be9e2c8
50 files changed
+3144
-60
No files matched your search
+48
@@ -0,0 +1,48 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Contracts.Responses.Scheduling;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.Scheduling;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="SchedulerDisplayPreferencesEntity"/>.
|
||||
/// </summary>
|
||||
public static class SchedulerDisplayPreferencesEntityMapping
|
||||
{
|
||||
private const int DEFAULT_DISPLAY_TIME_SPAN = 10;
|
||||
private const SchedulerDisplayTimeUnit DEFAULT_DISPLAY_TIME_UNIT = SchedulerDisplayTimeUnit.Minutes;
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="SchedulerDisplayPreferencesResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static SchedulerDisplayPreferencesResponse ToResponse(this SchedulerDisplayPreferencesEntity repositoryEntity)
|
||||
{
|
||||
return new SchedulerDisplayPreferencesResponse(
|
||||
repositoryEntity.UserId,
|
||||
repositoryEntity.JobTypeFilter,
|
||||
repositoryEntity.DisplayTimeSpan,
|
||||
repositoryEntity.DisplayTimeUnit
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the lack of stored display preferences to the default <see cref="SchedulerDisplayPreferencesResponse"/> of the user identified by <paramref name="userId"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The missing repository entity, which is <see langword="null"/>.</param>
|
||||
/// <param name="userId">The Id of the user that owns the display preferences.</param>
|
||||
/// <returns>The converted response with the default display preferences.</returns>
|
||||
public static SchedulerDisplayPreferencesResponse ToDefaultResponse(this SchedulerDisplayPreferencesEntity? repositoryEntity, Guid userId)
|
||||
{
|
||||
return new SchedulerDisplayPreferencesResponse(
|
||||
userId,
|
||||
null,
|
||||
DEFAULT_DISPLAY_TIME_SPAN,
|
||||
DEFAULT_DISPLAY_TIME_UNIT
|
||||
);
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.Scheduling.Commands.UpdateSchedulerDisplayPreferences;
|
||||
using Lumina.Contracts.Requests.Scheduling;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.Scheduling;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="UpdateSchedulerDisplayPreferencesRequest"/>.
|
||||
/// </summary>
|
||||
public static class UpdateSchedulerDisplayPreferencesRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="UpdateSchedulerDisplayPreferencesCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted command.</returns>
|
||||
public static UpdateSchedulerDisplayPreferencesCommand ToCommand(this UpdateSchedulerDisplayPreferencesRequest request)
|
||||
{
|
||||
return new UpdateSchedulerDisplayPreferencesCommand(
|
||||
request.JobTypeFilter,
|
||||
request.DisplayTimeSpan,
|
||||
request.DisplayTimeUnit
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user