mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 05:11:10 +00:00
Centralizes audit column ownership in the auditing interceptor
Removes explicit audit assignments from mappings, handlers, repositories, seeding, and background jobs, leaving the auditing interceptor as the only writer of the audit columns for ordinary saves. Adds a one-time initialization save so setup can attribute the original admin account and seeded rows to the SYSTEM audit identity, while ordinary anonymous writes remain unattributed with Guid.Empty.
This commit is contained in:
1 parent
b56fabf5df
commit
7253f1507c
98 files changed
+731
-516
No files matched your search
@@ -0,0 +1,20 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the fixed audit identities used by the persistence layer.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The SYSTEM identity is only for the explicit one-time application initialization save. Ordinary anonymous creation and modification remain
|
||||
/// unattributed with <see cref="Guid.Empty"/>; the SYSTEM identity is never inferred from a missing authenticated user.
|
||||
/// </remarks>
|
||||
public static class AuditIdentities
|
||||
{
|
||||
/// <summary>
|
||||
/// The fixed identifier of the SYSTEM audit user, used for rows created during application initialization, before any user account exists.
|
||||
/// </summary>
|
||||
public static readonly Guid s_systemUserId = Guid.Parse("11111111-1111-1111-1111-111111111111");
|
||||
}
|
||||
@@ -40,12 +40,12 @@ public class FavoriteEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
public DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
@@ -55,5 +55,5 @@ public class FavoriteEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+3
-3
@@ -99,12 +99,12 @@ public class MediaConsumptionRecordEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
public DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
@@ -114,5 +114,5 @@ public class MediaConsumptionRecordEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+3
-3
@@ -73,12 +73,12 @@ public class MediaResumePointEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
public DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
@@ -88,5 +88,5 @@ public class MediaResumePointEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+3
-3
@@ -46,12 +46,12 @@ public class MediaContributorEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
public DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
@@ -61,5 +61,5 @@ public class MediaContributorEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+2
-2
@@ -37,12 +37,12 @@ public class AlbumContributorEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
public DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
|
||||
+3
-3
@@ -245,12 +245,12 @@ public class AlbumEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
public DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
@@ -260,5 +260,5 @@ public class AlbumEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+2
-2
@@ -37,12 +37,12 @@ public class ArtistContributorEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
public DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
|
||||
+3
-3
@@ -164,12 +164,12 @@ public class ArtistEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
public DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
@@ -179,5 +179,5 @@ public class ArtistEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+3
-3
@@ -72,12 +72,12 @@ public class MusicArtworkEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
public DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
@@ -87,5 +87,5 @@ public class MusicArtworkEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+2
-2
@@ -37,12 +37,12 @@ public class TrackContributorEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
public DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
|
||||
+3
-3
@@ -305,12 +305,12 @@ public class TrackEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
public DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
@@ -320,5 +320,5 @@ public class TrackEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+3
-3
@@ -121,12 +121,12 @@ public class LibraryEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
public DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
@@ -136,5 +136,5 @@ public class LibraryEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+3
-3
@@ -53,12 +53,12 @@ public class LibraryScanEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
public DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
@@ -68,5 +68,5 @@ public class LibraryScanEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+3
-3
@@ -50,12 +50,12 @@ public class LibraryScanSnapshotEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
public DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
@@ -65,5 +65,5 @@ public class LibraryScanSnapshotEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+3
-3
@@ -65,12 +65,12 @@ public class BookArtworkEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
public DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
@@ -80,5 +80,5 @@ public class BookArtworkEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+2
-2
@@ -37,12 +37,12 @@ public class BookContributorEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
public DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
|
||||
+3
-3
@@ -241,12 +241,12 @@ public class BookEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
public DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
@@ -256,5 +256,5 @@ public class BookEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
@@ -61,12 +61,12 @@ public class PlaylistEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
public DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
@@ -76,5 +76,5 @@ public class PlaylistEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+3
-3
@@ -40,12 +40,12 @@ public class LibraryArtworkProviderConfigurationEntity : IStorageEntity, IAudita
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
public DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
@@ -55,5 +55,5 @@ public class LibraryArtworkProviderConfigurationEntity : IStorageEntity, IAudita
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+3
-3
@@ -35,12 +35,12 @@ public class LibraryBookReaderConfigurationEntity : IStorageEntity, IAuditableEn
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
public DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
@@ -50,5 +50,5 @@ public class LibraryBookReaderConfigurationEntity : IStorageEntity, IAuditableEn
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+3
-3
@@ -40,12 +40,12 @@ public class LibraryMetadataProviderConfigurationEntity : IStorageEntity, IAudit
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
public DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
@@ -55,5 +55,5 @@ public class LibraryMetadataProviderConfigurationEntity : IStorageEntity, IAudit
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
@@ -56,12 +56,12 @@ public class PluginEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
public DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
@@ -71,5 +71,5 @@ public class PluginEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
@@ -71,12 +71,12 @@ public class ScheduledJobEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
public DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
@@ -86,5 +86,5 @@ public class ScheduledJobEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+3
-3
@@ -56,12 +56,12 @@ public class ScheduledJobExecutionEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
public DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
@@ -71,5 +71,5 @@ public class ScheduledJobExecutionEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+3
-3
@@ -41,12 +41,12 @@ public class SchedulerDisplayPreferencesEntity : IStorageEntity, IAuditableEntit
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
public DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
@@ -56,5 +56,5 @@ public class SchedulerDisplayPreferencesEntity : IStorageEntity, IAuditableEntit
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
@@ -71,12 +71,12 @@ public class ThemeEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
public DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
@@ -86,5 +86,5 @@ public class ThemeEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
@@ -15,26 +15,23 @@ public interface IDataSeedService
|
||||
/// <summary>
|
||||
/// Sets up default authorization permissions in the system.
|
||||
/// </summary>
|
||||
/// <param name="adminId">The unique identifier of the admin admin user who will own these permissions.</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<Created>> SetDefaultAuthorizationPermissionsAsync(Guid adminId, CancellationToken cancellationToken);
|
||||
Task<Result<Created>> SetDefaultAuthorizationPermissionsAsync(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Sets up default authorization roles in the system.
|
||||
/// </summary>
|
||||
/// <param name="userId">The unique identifier of the admin user for whom roles will be set.</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<Created>> SetDefaultAuthorizationRolesAsync(Guid userId, CancellationToken cancellationToken);
|
||||
Task<Result<Created>> SetDefaultAuthorizationRolesAsync(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Assigns admin role permissions to the admin user.
|
||||
/// </summary>
|
||||
/// <param name="userId">The unique identifier of the admin user to receive admin role permissions.</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<Created>> SetAdminRolePermissionsAsync(Guid userId, CancellationToken cancellationToken);
|
||||
Task<Result<Created>> SetAdminRolePermissionsAsync(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Assigns admin role to the admin user.
|
||||
|
||||
@@ -185,6 +185,14 @@ public interface IUnitOfWork
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
Task<Result<Success>> SaveChangesAsync(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Saves the changes made during the one-time application initialization, whose audit values are provided explicitly by the bootstrap code instead of
|
||||
/// being stamped by the auditing interceptor.
|
||||
/// </summary>
|
||||
/// <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>> SaveChangesAsInitializationAsync(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Detaches all the entities tracked by the unit of work, freeing the memory they occupy.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Favorites;
|
||||
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.Favorites;
|
||||
@@ -23,11 +22,7 @@ public static class FavoriteMapping
|
||||
Id = domainEntity.Id.Value,
|
||||
UserId = domainEntity.UserId.Value,
|
||||
MediaKind = domainEntity.MediaKind,
|
||||
MediaItemId = domainEntity.MediaItemId.Value,
|
||||
CreatedOnUtc = domainEntity.CreatedOnUtc,
|
||||
CreatedBy = Guid.Empty,
|
||||
UpdatedOnUtc = domainEntity.UpdatedOnUtc.HasValue ? domainEntity.UpdatedOnUtc.Value : null,
|
||||
UpdatedBy = null
|
||||
MediaItemId = domainEntity.MediaItemId.Value
|
||||
};
|
||||
}
|
||||
}
|
||||
+1
-6
@@ -44,12 +44,7 @@ public static class MediaConsumptionRecordMapping
|
||||
: null,
|
||||
LastProgressFraction = domainEntity.LastProgressFraction,
|
||||
ConsecutivePagesRead = domainEntity.ConsecutivePagesRead,
|
||||
Version = 1,
|
||||
CreatedOnUtc = domainEntity.CreatedOnUtc,
|
||||
CreatedBy = Guid.Empty,
|
||||
// The audit columns are owned by the auditing interceptor, so they are never mapped here.
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null
|
||||
Version = 1
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -37,12 +37,7 @@ public static class MediaResumePointMapping
|
||||
: null,
|
||||
LastProgressFraction = domainEntity.LastProgressFraction,
|
||||
LastConsumedOnUtc = domainEntity.LastConsumedOnUtc,
|
||||
Version = 1,
|
||||
CreatedOnUtc = domainEntity.CreatedOnUtc,
|
||||
CreatedBy = Guid.Empty,
|
||||
// The audit columns are owned by the auditing interceptor, so they are never mapped here.
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null
|
||||
Version = 1
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+2
-10
@@ -69,18 +69,10 @@ public static class AlbumMapping
|
||||
Id = Guid.CreateVersion7(),
|
||||
AlbumId = domainEntity.Id.Value,
|
||||
MediaContributorId = contributor.ContributorId.Value,
|
||||
Role = contributor.Role,
|
||||
CreatedOnUtc = domainEntity.CreatedOnUtc,
|
||||
CreatedBy = Guid.Empty,
|
||||
UpdatedBy = null
|
||||
Role = contributor.Role
|
||||
})],
|
||||
Ratings = [.. domainEntity.Ratings.ToRepositoryEntities()],
|
||||
Tracks = [.. domainEntity.Tracks.Select(track => track.ToRepositoryEntity(domainEntity.Id.Value, libraryId))],
|
||||
CreatedOnUtc = domainEntity.CreatedOnUtc,
|
||||
CreatedBy = Guid.Empty,
|
||||
// The audit columns are owned by the auditing interceptor, which stamps only the rows that actually changed, so they are never mapped here.
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null
|
||||
Tracks = [.. domainEntity.Tracks.Select(track => track.ToRepositoryEntity(domainEntity.Id.Value, libraryId))]
|
||||
};
|
||||
}
|
||||
}
|
||||
+2
-10
@@ -51,17 +51,9 @@ public static class ArtistMapping
|
||||
Id = Guid.CreateVersion7(),
|
||||
ArtistId = domainEntity.Id.Value,
|
||||
MediaContributorId = contributor.ContributorId.Value,
|
||||
Role = contributor.Role,
|
||||
CreatedOnUtc = domainEntity.CreatedOnUtc,
|
||||
CreatedBy = Guid.Empty,
|
||||
UpdatedBy = null
|
||||
Role = contributor.Role
|
||||
})],
|
||||
Albums = [.. domainEntity.Albums.Select(album => album.ToRepositoryEntity(domainEntity.Id.Value, domainEntity.LibraryId.Value))],
|
||||
CreatedOnUtc = domainEntity.CreatedOnUtc,
|
||||
CreatedBy = Guid.Empty,
|
||||
// The audit columns are owned by the auditing interceptor, which stamps only the rows that actually changed, so they are never mapped here.
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null
|
||||
Albums = [.. domainEntity.Albums.Select(album => album.ToRepositoryEntity(domainEntity.Id.Value, domainEntity.LibraryId.Value))]
|
||||
};
|
||||
}
|
||||
}
|
||||
+2
-10
@@ -75,10 +75,7 @@ public static class TrackMapping
|
||||
Id = Guid.CreateVersion7(),
|
||||
TrackId = domainEntity.Id.Value,
|
||||
MediaContributorId = contributor.ContributorId.Value,
|
||||
Role = contributor.Role,
|
||||
CreatedOnUtc = domainEntity.CreatedOnUtc,
|
||||
CreatedBy = Guid.Empty,
|
||||
UpdatedBy = null
|
||||
Role = contributor.Role
|
||||
})],
|
||||
Moods = [.. domainEntity.Moods.ToRepositoryEntities()],
|
||||
Isrcs = [.. domainEntity.Isrcs.ToRepositoryEntities()],
|
||||
@@ -88,12 +85,7 @@ public static class TrackMapping
|
||||
WorkIswcs = domainEntity.Work.HasValue
|
||||
? [.. domainEntity.Work.Value.Iswcs.Select(iswc => new TrackWorkIswcEntity(iswc))]
|
||||
: [],
|
||||
Ratings = [.. domainEntity.Ratings.ToRepositoryEntities()],
|
||||
CreatedOnUtc = domainEntity.CreatedOnUtc,
|
||||
CreatedBy = Guid.Empty,
|
||||
// The audit columns are owned by the auditing interceptor, which stamps only the rows that actually changed, so they are never mapped here.
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null
|
||||
Ratings = [.. domainEntity.Ratings.ToRepositoryEntities()]
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using System;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
@@ -51,16 +50,8 @@ public static class LibraryMapping
|
||||
UserId = domainEntity.UserId.Value, // Rest of properties will be populated by EF Core.
|
||||
Status = default,
|
||||
User = null!,
|
||||
Library = null!,
|
||||
CreatedBy = default,
|
||||
CreatedOnUtc = default,
|
||||
UpdatedBy = default,
|
||||
})],
|
||||
CreatedOnUtc = domainEntity.CreatedOnUtc,
|
||||
CreatedBy = Guid.Empty,
|
||||
// The audit columns are owned by the auditing interceptor, which stamps only the rows that actually changed, so they are never mapped here.
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null
|
||||
Library = null!
|
||||
})]
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
@@ -25,11 +24,7 @@ public static class LibraryScanMapping
|
||||
LibraryId = domainEntity.LibraryId.Value,
|
||||
Status = domainEntity.Status,
|
||||
User = null!,
|
||||
Library = null!,
|
||||
CreatedOnUtc = domainEntity.CreatedOnUtc,
|
||||
CreatedBy = Guid.Empty,
|
||||
UpdatedOnUtc = domainEntity.UpdatedOnUtc.HasValue ? domainEntity.UpdatedOnUtc.Value : null,
|
||||
UpdatedBy = Guid.Empty
|
||||
Library = null!
|
||||
};
|
||||
}
|
||||
}
|
||||
+2
-12
@@ -63,17 +63,9 @@ public static class BookMapping
|
||||
Id = Guid.CreateVersion7(),
|
||||
BookId = domainEntity.Id.Value,
|
||||
MediaContributorId = contributor.ContributorId.Value,
|
||||
Role = contributor.Role,
|
||||
CreatedOnUtc = domainEntity.CreatedOnUtc,
|
||||
CreatedBy = Guid.Empty,
|
||||
UpdatedBy = null
|
||||
Role = contributor.Role
|
||||
})],
|
||||
Ratings = [.. domainEntity.Ratings.ToRepositoryEntities()],
|
||||
CreatedOnUtc = domainEntity.CreatedOnUtc,
|
||||
CreatedBy = Guid.Empty,
|
||||
// The audit columns are owned by the auditing interceptor, which stamps only the rows that actually changed, so they are never mapped here.
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null,
|
||||
Ratings = [.. domainEntity.Ratings.ToRepositoryEntities()]
|
||||
};
|
||||
}
|
||||
|
||||
@@ -114,7 +106,5 @@ public static class BookMapping
|
||||
entity.GoogleBooksId = domainEntity.GoogleBooksId.HasValue ? domainEntity.GoogleBooksId.Value : null;
|
||||
entity.BarnesAndNobleId = domainEntity.BarnesAndNobleId.HasValue ? domainEntity.BarnesAndNobleId.Value : null;
|
||||
entity.AppleBooksId = domainEntity.AppleBooksId.HasValue ? domainEntity.AppleBooksId.Value : null;
|
||||
entity.UpdatedOnUtc = DateTime.UtcNow;
|
||||
entity.UpdatedBy = Guid.CreateVersion7();
|
||||
}
|
||||
}
|
||||
+2
-8
@@ -21,9 +21,8 @@ public static class UpdateBookCoverCommandMapping
|
||||
/// <param name="existingCover">The existing cover artwork of the book, or <see langword="null"/> when the book has none.</param>
|
||||
/// <param name="bookId">The Id of the book the cover belongs to.</param>
|
||||
/// <param name="storedCoverPath">The relative path of the stored cover image.</param>
|
||||
/// <param name="userId">The Id of the user that stored the cover image.</param>
|
||||
/// <returns>The cover artwork of the book, carrying the stored cover image.</returns>
|
||||
public static BookArtworkEntity ToRepositoryEntity(this UpdateBookCoverCommand command, BookArtworkEntity? existingCover, Guid bookId, string storedCoverPath, Guid userId)
|
||||
public static BookArtworkEntity ToRepositoryEntity(this UpdateBookCoverCommand command, BookArtworkEntity? existingCover, Guid bookId, string storedCoverPath)
|
||||
{
|
||||
if (existingCover is null)
|
||||
{
|
||||
@@ -34,18 +33,13 @@ public static class UpdateBookCoverCommandMapping
|
||||
ArtworkType = ArtworkType.Cover,
|
||||
Ordinal = 0,
|
||||
FileName = storedCoverPath,
|
||||
Status = ArtworkStatus.Enriched,
|
||||
CreatedOnUtc = DateTime.UtcNow,
|
||||
CreatedBy = userId,
|
||||
UpdatedBy = null
|
||||
Status = ArtworkStatus.Enriched
|
||||
};
|
||||
}
|
||||
|
||||
existingCover.FileName = storedCoverPath;
|
||||
existingCover.Status = ArtworkStatus.Enriched;
|
||||
existingCover.LastUpdateUtc = DateTime.UtcNow;
|
||||
existingCover.UpdatedOnUtc = DateTime.UtcNow;
|
||||
existingCover.UpdatedBy = userId;
|
||||
return existingCover;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Playlists;
|
||||
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate;
|
||||
using System;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
@@ -30,11 +29,7 @@ public static class PlaylistMapping
|
||||
.OrderBy(entry => entry.Position)
|
||||
.Select(entry => entry.ToRepositoryEntity(domainEntity.Id.Value))],
|
||||
// This is the correct count for an insert. The update path deliberately keeps the stored count, because details edits never load the entries and must not overwrite it.
|
||||
EntryCount = domainEntity.Entries.Count,
|
||||
CreatedOnUtc = domainEntity.CreatedOnUtc,
|
||||
CreatedBy = Guid.Empty,
|
||||
UpdatedOnUtc = domainEntity.UpdatedOnUtc.HasValue ? domainEntity.UpdatedOnUtc.Value : null,
|
||||
UpdatedBy = null
|
||||
EntryCount = domainEntity.Entries.Count
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -99,11 +99,7 @@ public static class ScheduledJobEntityMapping
|
||||
Status = status,
|
||||
OwnerUserId = repositoryEntity.OwnerUserId,
|
||||
LastStartedOnUtc = lastStartedOnUtc,
|
||||
LastCompletedOnUtc = lastCompletedOnUtc,
|
||||
CreatedOnUtc = repositoryEntity.CreatedOnUtc,
|
||||
CreatedBy = repositoryEntity.CreatedBy,
|
||||
UpdatedOnUtc = repositoryEntity.UpdatedOnUtc,
|
||||
UpdatedBy = repositoryEntity.UpdatedBy
|
||||
LastCompletedOnUtc = lastCompletedOnUtc
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+1
-5
@@ -44,11 +44,7 @@ public static class ScheduledJobExecutionEntityMapping
|
||||
IsCycleRun = repositoryEntity.IsCycleRun,
|
||||
WasCycleActive = repositoryEntity.WasCycleActive,
|
||||
StartedOnUtc = repositoryEntity.StartedOnUtc,
|
||||
CompletedOnUtc = completedOnUtc,
|
||||
CreatedOnUtc = repositoryEntity.CreatedOnUtc,
|
||||
CreatedBy = repositoryEntity.CreatedBy,
|
||||
UpdatedOnUtc = repositoryEntity.UpdatedOnUtc,
|
||||
UpdatedBy = repositoryEntity.UpdatedBy
|
||||
CompletedOnUtc = completedOnUtc
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ using Lumina.Application.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Contracts.Responses.Scheduling;
|
||||
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.Scheduling;
|
||||
@@ -32,11 +31,7 @@ public static class ScheduledJobMapping
|
||||
Status = domainEntity.Status,
|
||||
OwnerUserId = domainEntity.OwnerUserId.Value,
|
||||
LastStartedOnUtc = domainEntity.LastStartedOnUtc.HasValue ? domainEntity.LastStartedOnUtc.Value : null,
|
||||
LastCompletedOnUtc = domainEntity.LastCompletedOnUtc.HasValue ? domainEntity.LastCompletedOnUtc.Value : null,
|
||||
CreatedOnUtc = domainEntity.CreatedOnUtc,
|
||||
CreatedBy = Guid.Empty,
|
||||
UpdatedOnUtc = domainEntity.UpdatedOnUtc.HasValue ? domainEntity.UpdatedOnUtc.Value : null,
|
||||
UpdatedBy = Guid.Empty
|
||||
LastCompletedOnUtc = domainEntity.LastCompletedOnUtc.HasValue ? domainEntity.LastCompletedOnUtc.Value : null
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+6
-5
@@ -1,5 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Application.Common.DataAccess.Seed;
|
||||
@@ -107,7 +108,7 @@ public class SetupApplicationCommandHandler : ICommandHandler<SetupApplicationCo
|
||||
Libraries = [],
|
||||
UserPermissions = [],
|
||||
UserRole = null,
|
||||
CreatedBy = id,
|
||||
CreatedBy = AuditIdentities.s_systemUserId,
|
||||
LibraryScans = [],
|
||||
};
|
||||
// If the user enabled two factor auth, include a QR with the totp secret.
|
||||
@@ -124,20 +125,20 @@ public class SetupApplicationCommandHandler : ICommandHandler<SetupApplicationCo
|
||||
Result<Created> insertUserResult = await _unitOfWork.UserRepository.InsertAsync(user, cancellationToken).ConfigureAwait(false);
|
||||
if (insertUserResult.IsFailure)
|
||||
return insertUserResult.Errors;
|
||||
Result<Success> saveChangesResult = await _unitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
|
||||
Result<Success> saveChangesResult = await _unitOfWork.SaveChangesAsInitializationAsync(cancellationToken).ConfigureAwait(false);
|
||||
if (saveChangesResult.IsFailure)
|
||||
return saveChangesResult.Errors;
|
||||
|
||||
// Set the default permissions, roles, roles permissions.
|
||||
Result<Created> setPermissionsResult = await _dataSeedService.SetDefaultAuthorizationPermissionsAsync(id, cancellationToken).ConfigureAwait(false);
|
||||
Result<Created> setPermissionsResult = await _dataSeedService.SetDefaultAuthorizationPermissionsAsync(cancellationToken).ConfigureAwait(false);
|
||||
if (setPermissionsResult.IsFailure)
|
||||
return setPermissionsResult.Errors;
|
||||
|
||||
Result<Created> setRoleResult = await _dataSeedService.SetDefaultAuthorizationRolesAsync(id, cancellationToken).ConfigureAwait(false);
|
||||
Result<Created> setRoleResult = await _dataSeedService.SetDefaultAuthorizationRolesAsync(cancellationToken).ConfigureAwait(false);
|
||||
if (setRoleResult.IsFailure)
|
||||
return setRoleResult.Errors;
|
||||
|
||||
Result<Created> setRolePermissionResult = await _dataSeedService.SetAdminRolePermissionsAsync(id, cancellationToken).ConfigureAwait(false);
|
||||
Result<Created> setRolePermissionResult = await _dataSeedService.SetAdminRolePermissionsAsync(cancellationToken).ConfigureAwait(false);
|
||||
if (setRolePermissionResult.IsFailure)
|
||||
return setRolePermissionResult.Errors;
|
||||
|
||||
|
||||
+1
-1
@@ -122,7 +122,7 @@ public class UpdateBookCoverCommandHandler : ICommandHandler<UpdateBookCoverComm
|
||||
|
||||
// Map the newly stored cover image onto the artwork of the book, replacing the existing cover or adding a new one.
|
||||
BookArtworkEntity? existingCover = existingBook.Artwork.FirstOrDefault(artwork => artwork.ArtworkType == ArtworkType.Cover);
|
||||
BookArtworkEntity coverArtwork = command.ToRepositoryEntity(existingCover, bookId, storeArtworkResult.Value, userId);
|
||||
BookArtworkEntity coverArtwork = command.ToRepositoryEntity(existingCover, bookId, storeArtworkResult.Value);
|
||||
if (existingCover is null)
|
||||
existingBook.Artwork.Add(coverArtwork);
|
||||
|
||||
|
||||
+1
-5
@@ -71,11 +71,7 @@ public class UpdateSchedulerDisplayPreferencesCommandHandler : ICommandHandler<U
|
||||
UserId = userId,
|
||||
JobTypeFilter = command.JobTypeFilter,
|
||||
DisplayTimeSpan = command.DisplayTimeSpan,
|
||||
DisplayTimeUnit = command.DisplayTimeUnit,
|
||||
CreatedOnUtc = default,
|
||||
CreatedBy = default,
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null
|
||||
DisplayTimeUnit = command.DisplayTimeUnit
|
||||
};
|
||||
Result<Updated> upsertResult = await _unitOfWork.SchedulerDisplayPreferencesRepository.UpsertAsync(displayPreferences, cancellationToken).ConfigureAwait(false);
|
||||
if (upsertResult.IsFailure)
|
||||
|
||||
+1
-5
@@ -72,11 +72,7 @@ public class ScheduledJobExecutionStartedDomainEventHandler : IDomainEventHandle
|
||||
IsCycleRun = domainEvent.IsCycleRun,
|
||||
WasCycleActive = wasCycleActive,
|
||||
StartedOnUtc = domainEvent.StartedOnUtc,
|
||||
CompletedOnUtc = null,
|
||||
CreatedOnUtc = scheduledJob.CreatedOnUtc,
|
||||
CreatedBy = scheduledJob.CreatedBy,
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null
|
||||
CompletedOnUtc = null
|
||||
};
|
||||
Result<Created> insertExecutionResult = await _unitOfWork.ScheduledJobExecutionRepository.InsertAsync(execution, cancellationToken).ConfigureAwait(false);
|
||||
if (insertExecutionResult.IsFailure)
|
||||
|
||||
-2
@@ -119,8 +119,6 @@ public class DeleteThemeCommandHandler : ICommandHandler<DeleteThemeCommand, Res
|
||||
// Bundled themes are soft deleted, so they can be restored automatically later, as long as the user did not delete them.
|
||||
theme.IsDeleted = true;
|
||||
theme.IsCurrent = null;
|
||||
theme.UpdatedOnUtc = DateTime.UtcNow;
|
||||
theme.UpdatedBy = userId;
|
||||
await _unitOfWork.ThemeRepository.UpdateAsync(theme, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
|
||||
+2
-9
@@ -103,11 +103,7 @@ public class InstallThemeCommandHandler : ICommandHandler<InstallThemeCommand, R
|
||||
IsCurrent = existingTheme.IsCurrent,
|
||||
// Reinstalling a theme must bring it back even if it was soft deleted before, so the uploaded pack becomes visible again.
|
||||
IsDeleted = false,
|
||||
InstalledAtUtc = DateTime.UtcNow,
|
||||
CreatedOnUtc = existingTheme.CreatedOnUtc,
|
||||
CreatedBy = existingTheme.CreatedBy,
|
||||
UpdatedOnUtc = DateTime.UtcNow,
|
||||
UpdatedBy = userId
|
||||
InstalledAtUtc = DateTime.UtcNow
|
||||
};
|
||||
|
||||
Result<Updated> updateResult = await _unitOfWork.ThemeRepository.UpdateAsync(themeEntity, cancellationToken).ConfigureAwait(false);
|
||||
@@ -126,10 +122,7 @@ public class InstallThemeCommandHandler : ICommandHandler<InstallThemeCommand, R
|
||||
Version = manifest.Version,
|
||||
PreviewPath = manifest.Preview,
|
||||
InstallSource = ThemeInstallSource.Uploaded,
|
||||
InstalledAtUtc = DateTime.UtcNow,
|
||||
CreatedOnUtc = DateTime.UtcNow,
|
||||
CreatedBy = userId,
|
||||
UpdatedBy = userId
|
||||
InstalledAtUtc = DateTime.UtcNow
|
||||
};
|
||||
|
||||
Result<Created> insertResult = await _unitOfWork.ThemeRepository.InsertAsync(themeEntity, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
-2
@@ -93,8 +93,6 @@ public class RestoreThemeCommandHandler : ICommandHandler<RestoreThemeCommand, R
|
||||
|
||||
theme.IsDeleted = false;
|
||||
theme.IsCurrent = null;
|
||||
theme.UpdatedOnUtc = DateTime.UtcNow;
|
||||
theme.UpdatedBy = userId;
|
||||
Result<Updated> updateResult = await _unitOfWork.ThemeRepository.UpdateAsync(theme, cancellationToken).ConfigureAwait(false);
|
||||
if (updateResult.IsFailure)
|
||||
return updateResult.Errors;
|
||||
|
||||
-2
@@ -96,8 +96,6 @@ public class SetCurrentThemeCommandHandler : ICommandHandler<SetCurrentThemeComm
|
||||
|
||||
// Activate the requested theme and persist its update.
|
||||
theme.IsCurrent = true;
|
||||
theme.UpdatedOnUtc = DateTime.UtcNow;
|
||||
theme.UpdatedBy = userId;
|
||||
await _unitOfWork.ThemeRepository.UpdateAsync(theme, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
Result<Success> saveChangesResult = await _unitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
-7
@@ -7,7 +7,6 @@ using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.Errors;
|
||||
using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
using Lumina.Application.Common.Infrastructure.Security;
|
||||
using Lumina.Application.Common.Infrastructure.Time;
|
||||
using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Contracts.Responses.Authentication;
|
||||
using System;
|
||||
@@ -28,7 +27,6 @@ public class RegisterUserCommandHandler : ICommandHandler<RegisterUserCommand, R
|
||||
private readonly ICryptographyService _cryptographyService;
|
||||
private readonly ITotpTokenGenerator _totpTokenGenerator;
|
||||
private readonly IQRCodeGenerator _qRCodeGenerator;
|
||||
private readonly IDateTimeProvider _dateTimeProvider;
|
||||
private readonly IValidator<RegisterUserCommand> _validator;
|
||||
|
||||
/// <summary>
|
||||
@@ -39,7 +37,6 @@ public class RegisterUserCommandHandler : ICommandHandler<RegisterUserCommand, R
|
||||
/// <param name="cryptographyService">Injected service for cryptographic functionality.</param>
|
||||
/// <param name="totpTokenGenerator">Injected service for generating and validating TOTP tokens.</param>
|
||||
/// <param name="qRCodeGenerator">Injected service for generating QR codes.</param>
|
||||
/// <param name="dateTimeProvider">Injected service for time related concerns.</param>
|
||||
/// <param name="validator">Injected validator for application validation rules.</param>
|
||||
public RegisterUserCommandHandler(
|
||||
IUnitOfWork unitOfWork,
|
||||
@@ -47,7 +44,6 @@ public class RegisterUserCommandHandler : ICommandHandler<RegisterUserCommand, R
|
||||
ICryptographyService cryptographyService,
|
||||
ITotpTokenGenerator totpTokenGenerator,
|
||||
IQRCodeGenerator qRCodeGenerator,
|
||||
IDateTimeProvider dateTimeProvider,
|
||||
IValidator<RegisterUserCommand> validator)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
@@ -55,7 +51,6 @@ public class RegisterUserCommandHandler : ICommandHandler<RegisterUserCommand, R
|
||||
_cryptographyService = cryptographyService;
|
||||
_totpTokenGenerator = totpTokenGenerator;
|
||||
_qRCodeGenerator = qRCodeGenerator;
|
||||
_dateTimeProvider = dateTimeProvider;
|
||||
_validator = validator;
|
||||
}
|
||||
|
||||
@@ -88,11 +83,9 @@ public class RegisterUserCommandHandler : ICommandHandler<RegisterUserCommand, R
|
||||
Id = id,
|
||||
Username = command.Username!,
|
||||
Password = Uri.EscapeDataString(_hashService.HashString(command.Password!)),
|
||||
CreatedOnUtc = _dateTimeProvider.UtcNow,
|
||||
Libraries = [],
|
||||
UserPermissions = [],
|
||||
UserRole = null,
|
||||
CreatedBy = id,
|
||||
LibraryScans = [],
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user