diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml
index 5ae23348..975227db 100644
--- a/.github/workflows/run-tests.yml
+++ b/.github/workflows/run-tests.yml
@@ -4,10 +4,14 @@ on:
pull_request:
branches:
- master
+ workflow_dispatch: # enable manual triggers
jobs:
- test:
- runs-on: ubuntu-latest
+ run-platform-tests:
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@v2
- name: Set up .NET
diff --git a/.github/workflows/validate-branch-name.yml b/.github/workflows/validate-branch-name.yml
index ff40b40d..ed7c8625 100644
--- a/.github/workflows/validate-branch-name.yml
+++ b/.github/workflows/validate-branch-name.yml
@@ -1,4 +1,4 @@
-name: Branch Naming Convention Check
+name: Branch Push Naming Convention Check
on:
push:
@@ -6,7 +6,7 @@ on:
- master
jobs:
- check-branch-name:
+ validate-branch-push:
runs-on: ubuntu-latest
steps:
- name: Check branch name
diff --git a/.github/workflows/validate-pull-request-source-branch.yml b/.github/workflows/validate-pull-request-source-branch.yml
index bd378bd6..3c28e6bc 100644
--- a/.github/workflows/validate-pull-request-source-branch.yml
+++ b/.github/workflows/validate-pull-request-source-branch.yml
@@ -1,4 +1,4 @@
-name: PR Source Branch Check
+name: Pull Request Source Branch Validation Check
on:
pull_request:
@@ -6,7 +6,7 @@ on:
- master
jobs:
- check-branch-name:
+ validate-pr-source:
runs-on: ubuntu-latest
steps:
- name: Check source branch name
diff --git a/.gitignore b/.gitignore
index d507c4d1..925941ae 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,7 +31,8 @@ bld/
*.sln.iml
# Common
-*.Development.json
+*.[Dd]evelopment.json
+*.[Tt]est.json
# Windows image file caches
Thumbs.db
diff --git a/README.md b/README.md
index c3758e48..f45fd375 100644
--- a/README.md
+++ b/README.md
@@ -38,6 +38,8 @@ Several icons used in this project were adapted from icons sourced from [svgrepo
- [`toggle-thumbnails.svg`](https://www.svgrepo.com/svg/370469/page-image) (Public Domain license)
- [`toggle-hidden.svg`](https://www.svgrepo.com/svg/470389/hidden) (MIT License)
+- [`delete.svg`](https://www.svgrepo.com/svg/488148/delete) (MIT License)
+- [`add-directory.svg`](https://www.svgrepo.com/svg/488040/add-folder) (MIT License)
## License
diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md
index ea1fb5f2..0c02b96a 100644
--- a/docs/CONTRIBUTING.md
+++ b/docs/CONTRIBUTING.md
@@ -99,39 +99,11 @@ public interface IUserService
### C# Specific
#### Code Conventions:
-- Each class, interface and struct should use the following `#region`s to group code sections:
+- Group `using`s with the following `#region`:
```csharp
#region ========================================================================= USING =====================================================================================
using System;
#endregion
-
-namespace Current.Namespace;
-
-public class DhlDeliveryServiceProvider : IDeliveryServiceProvider
-{
- #region ================================================================== FIELD MEMBERS ================================================================================
- private readonly ITaxCalculator _taxCalculator;
- #endregion
-
- #region ====================================================================== CTOR =====================================================================================
- public GetDirectoryTreeQueryHandler(ITaxCalculator taxCalculator)
- {
- _taxCalculator = taxCalculator;
- }
- #endregion
-
- #region ===================================================================== METHODS ===================================================================================
- public void Deliver()
- {
- // code
- }
-
- public decimal CalculateCost()
- {
- // code
- }
- #endregion
-}
```
- Enforce one type per file. For example:
```csharp
diff --git a/docs/INSTALL.md b/docs/INSTALL.md
new file mode 100644
index 00000000..48d64613
--- /dev/null
+++ b/docs/INSTALL.md
@@ -0,0 +1,17 @@
+## Reverse Proxy Setup
+### Rate Limiting Headers
+The application uses IP-based rate limiting on some endpoints. When deploying behind a reverse proxy, you must forward the
+original client IP, otherwise the "per IP" rate limiting will become global, per any request aimed at those endpoints, regardless of origin:
+
+```text
+# Nginx
+proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+
+# Apache
+RemoteIPHeader X-Forwarded-For
+
+# Caddy
+reverse_proxy {
+ header_up X-Forwarded-For {remote_host}
+}
+```
diff --git a/docs/technical/domain/Aggregates.FileManagement.md b/docs/technical/domain/Aggregates.FileSystemManagement.md
similarity index 100%
rename from docs/technical/domain/Aggregates.FileManagement.md
rename to docs/technical/domain/Aggregates.FileSystemManagement.md
diff --git a/docs/technical/domain/Domain.md b/docs/technical/domain/Domain.md
new file mode 100644
index 00000000..1a7f872d
--- /dev/null
+++ b/docs/technical/domain/Domain.md
@@ -0,0 +1,76 @@
+Domain
+├── Audio Library Bounded Context
+│ └── Audio Library Aggregate
+│ └── Audio Metadata
+├── Video Library Bounded Context
+│ ├── Movie Library Aggregate
+│ │ ├── Movie Id
+│ │ ├── Video Metadata
+│ │ ├── Movie Library Service
+│ │ └── Movie
+│ ├── Tv Show Library Aggregate
+│ │ ├── Episode Id
+│ │ ├── Season Id
+│ │ ├── Tv Show Id
+│ │ ├── Episode
+│ │ ├── Season
+│ │ ├── Tv Show Library Service
+│ │ └── Tv Show
+│ └── Video Library Service
+├── Photo Library Bounded Context
+│ └── Photo Library Aggregate
+├── Written Content Library Bounded Context
+│ ├── Book Library Aggregate
+│ │ ├── Book Id
+│ │ ├── Book Rating
+│ │ ├── Book Series Id
+│ │ ├── ISBN
+│ │ ├── Written Content Metadata
+│ │ ├── Book Series
+│ │ ├── Book Library Service
+│ │ └── Book
+│ ├── Magazine Library Aggregate
+│ │ └── Magazine
+│ └── Written Content Library Service
+├── Media Contributor Bounded Context
+│ └── Media Contributor Aggregate
+│ ├── Contributor Name
+│ ├── Media Contributor Id
+│ ├── Media Contributor Role
+│ └── Media Contributor
+├── Library Management Bounded Context
+│ └── Library Aggregate
+│ ├── Library Id
+│ └── Library
+├── User Management Bounded Context
+│ └── User Aggregate
+│ ├── User Id
+│ └── User
+├── File System Management Bounded Context
+│ └── File System Management Aggregate
+│ ├── File System Path Id
+│ ├── Path Segment
+│ ├── Stream Info
+│ ├── Thumbnail
+│ ├── Directory
+│ ├── File
+│ ├── UNIX Root Item
+│ ├── Windows Root Item
+│ ├── Directory Provider Service
+│ ├── File Provider Service
+│ ├── Directory Service
+│ ├── File Service
+│ ├── Drive Service
+│ ├── Path Service
+│ ├── Thumbnail Service
+│ ├── File System Permissions Service
+│ ├── File Type Service
+│ └── File System Item
+
+• Bounded Context
+• Aggregate
+• Aggregate Root
+• Entity
+• Value Object
+• Event
+• Service
diff --git a/docs/technical/domain/UbiquitousLanguage.md b/docs/technical/domain/UbiquitousLanguage.md
index 6d935dc8..cf31fb0a 100644
--- a/docs/technical/domain/UbiquitousLanguage.md
+++ b/docs/technical/domain/UbiquitousLanguage.md
@@ -95,6 +95,7 @@
- ComicSeries
- Magazine
- MagazineIssue
+- Newspaper
- Manga
- GraphicNovel
- AcademicPaper
@@ -117,11 +118,11 @@
- VideoLibrary (root: VideoLibrary, entities: TVShow, Season, Episode, Movie, FilmSeries, ConcertVideo, Documentary, TutorialVideo, HomeVideo, Anime, YouTubeVideo, MusicVideo)
- AudioLibrary (root: AudioLibrary, entities: Song, Album, Artist, Audiobook, LiveRecording, Interview, CoverSong, Remix, SoundEffect)
- PodcastLibrary (root: PodcastLibrary, entities: Podcast, PodcastEpisode)
-- WrittenContentLibrary (root: WrittenContentLibrary, entities: Book, EBook, BookSeries, ComicBook, ComicSeries, Magazine, MagazineIssue, Manga, GraphicNovel, AcademicPaper, SheetMusic, Screenplay)
+- WrittenContentLibrary (root: WrittenContentLibrary, entities: Book, EBook, BookSeries, ComicBook, ComicSeries, Magazine, MagazineIssue, Newspaper, Manga, GraphicNovel, AcademicPaper, SheetMusic, Screenplay)
- PhotoLibrary (root: PhotoLibrary, entities: Photo, PhotoAlbum, AlbumArtwork, MoviePoster)
- UserProfile (root: User, entities: Playlist, Collection)
- SupplementaryContentLibrary (root: SupplementaryContentLibrary, entities: SubtitleFile, Lyrics, LanguageTrack)
-- FileManagement (root: File, entities: Stream)
+- FileSystemManagement (root: File, entities: Stream)
- WrittenContentLibrary
- BookLibrary (root: BookLibrary)
@@ -133,7 +134,7 @@
- Value Objects: ComicMetadata, SeriesInfo
- PeriodicalLibrary (root: PeriodicalLibrary)
- - Entities: Magazine, MagazineIssue
+ - Entities: Magazine, MagazineIssue, Newspaper
- Value Objects: PeriodicalMetadata, IssueInfo
- AcademicLibrary (root: AcademicLibrary)
@@ -219,7 +220,7 @@
- Aggregates: UserProfile
- Services: RecommendationEngine, ContentCurationService, UserActivityTrackingService
- ContentDelivery
- - Aggregates: FileManagement
+ - Aggregates: FileSystemManagement
- Services: StreamingService, ContentSynchronizationService
- MetadataManagement
- Aggregates: SupplementaryContentLibrary
@@ -235,4 +236,4 @@
- PlaylistRepository
- CollectionRepository
- FileRepository
-- StreamRepository
\ No newline at end of file
+- StreamRepository
diff --git a/src/Lumina.Application/Common/Converters/OptionalJsonConverter.cs b/src/Lumina.Application/Common/Converters/OptionalJsonConverter.cs
deleted file mode 100644
index 82585b97..00000000
--- a/src/Lumina.Application/Common/Converters/OptionalJsonConverter.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-#region ========================================================================= USING =====================================================================================
-using Lumina.Domain.Common.Primitives;
-using System;
-using System.Text.Json;
-using System.Text.Json.Serialization;
-#endregion
-
-namespace Lumina.Application.Common.Converters;
-
-///
-/// Converts an to and from JSON.
-///
-/// The type of the value represented by the structure.
-public class OptionalJsonConverter : JsonConverter>
-{
- ///
- /// Reads and converts the JSON to an instance of .
- ///
- /// The to read from.
- /// The type to convert.
- /// An object that specifies serialization options to use.
- /// The converted value.
- public override Optional Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
- {
- if (reader.TokenType == JsonTokenType.Null)
- return Optional.None();
- TValue? value = JsonSerializer.Deserialize(ref reader, options);
- return Optional.Some(value!);
- }
-
- ///
- /// Writes an value as JSON.
- ///
- /// The to write to.
- /// The value to convert to JSON.
- /// An object that specifies serialization options to use.
- public override void Write(Utf8JsonWriter writer, Optional value, JsonSerializerOptions options)
- {
- if (value.HasValue)
- JsonSerializer.Serialize(writer, value.Value, options);
- else
- writer.WriteNullValue();
- }
-}
\ No newline at end of file
diff --git a/src/Lumina.Application/Common/Converters/OptionalJsonConverterFactory.cs b/src/Lumina.Application/Common/Converters/OptionalJsonConverterFactory.cs
deleted file mode 100644
index 3bf7d378..00000000
--- a/src/Lumina.Application/Common/Converters/OptionalJsonConverterFactory.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-#region ========================================================================= USING =====================================================================================
-using Lumina.Domain.Common.Primitives;
-using System;
-using System.Text.Json;
-using System.Text.Json.Serialization;
-#endregion
-
-namespace Lumina.Application.Common.Converters;
-
-///
-/// A factory for creating instances.
-///
-public class OptionalJsonConverterFactory : JsonConverterFactory
-{
- ///
- /// Determines whether the converter can convert the specified type.
- ///
- /// The type to check for convertibility.
- /// if the type is , otherwise.
- public override bool CanConvert(Type typeToConvert)
- {
- return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(Optional<>);
- }
-
- ///
- /// Creates a converter for the specified type.
- ///
- /// The type for which to create a converter.
- /// The serializer options to use.
- /// A converter for .
- public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options)
- {
- Type valueType = typeToConvert.GetGenericArguments()[0];
- JsonConverter converter = (JsonConverter)Activator.CreateInstance(
- typeof(OptionalJsonConverter<>).MakeGenericType(valueType))!;
- return converter;
- }
-}
\ No newline at end of file
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/Common/GenreEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/Common/GenreEntity.cs
new file mode 100644
index 00000000..019ecd4a
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Entities/Common/GenreEntity.cs
@@ -0,0 +1,14 @@
+#region ========================================================================= USING =====================================================================================
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Entities.Common;
+
+///
+/// Represents a genre.
+///
+/// Gets the name of the genre.
+[DebuggerDisplay("Name: {Name}")]
+public record GenreEntity(
+ string? Name
+);
diff --git a/src/Lumina.Contracts/Models/Common/IStorageEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/Common/IStorageEntity.cs
similarity index 51%
rename from src/Lumina.Contracts/Models/Common/IStorageEntity.cs
rename to src/Lumina.Application/Common/DataAccess/Entities/Common/IStorageEntity.cs
index a35d558f..f3bb814e 100644
--- a/src/Lumina.Contracts/Models/Common/IStorageEntity.cs
+++ b/src/Lumina.Application/Common/DataAccess/Entities/Common/IStorageEntity.cs
@@ -1,8 +1,8 @@
-#region ========================================================================= USING =====================================================================================
+#region ========================================================================= USING =====================================================================================
using System;
#endregion
-namespace Lumina.Contracts.Models.Common;
+namespace Lumina.Application.Common.DataAccess.Entities.Common;
///
/// Interface for storage models, enforces Id.
@@ -15,12 +15,12 @@ public interface IStorageEntity
Guid Id { get; init; }
///
- /// The time and date when the entity was added.
+ /// Gets or sets the time and date when the entity was added.
///
DateTime Created { get; set; }
///
- /// The time and date when the entity was updated.
+ /// Gets or sets the optional time and date when the entity was updated.
///
DateTime? Updated { get; set; }
-}
\ No newline at end of file
+}
diff --git a/src/Lumina.Contracts/Models/Common/RatingModel.cs b/src/Lumina.Application/Common/DataAccess/Entities/Common/RatingEntity.cs
similarity index 85%
rename from src/Lumina.Contracts/Models/Common/RatingModel.cs
rename to src/Lumina.Application/Common/DataAccess/Entities/Common/RatingEntity.cs
index 86398053..5caef350 100644
--- a/src/Lumina.Contracts/Models/Common/RatingModel.cs
+++ b/src/Lumina.Application/Common/DataAccess/Entities/Common/RatingEntity.cs
@@ -2,7 +2,7 @@
using System.Diagnostics;
#endregion
-namespace Lumina.Contracts.Models.Common;
+namespace Lumina.Application.Common.DataAccess.Entities.Common;
///
/// Represents a rating.
@@ -11,8 +11,8 @@ namespace Lumina.Contracts.Models.Common;
/// Gets the maximum possible rating value.
/// Gets the number of votes that contributed to the rating.
[DebuggerDisplay("{Value}/{MaxValue}")]
-public abstract record RatingModel(
+public abstract record RatingEntity(
decimal? Value,
decimal? MaxValue,
int? VoteCount
-);
\ No newline at end of file
+);
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/Common/TagEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/Common/TagEntity.cs
new file mode 100644
index 00000000..f020608f
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Entities/Common/TagEntity.cs
@@ -0,0 +1,14 @@
+#region ========================================================================= USING =====================================================================================
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Entities.Common;
+
+///
+/// Represents a tag.
+///
+/// Gets the name of the tag.
+[DebuggerDisplay("Name: {Name}")]
+public record TagEntity(
+ string? Name
+);
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/FileSystemManagement/FileSystemItemEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/FileSystemManagement/FileSystemItemEntity.cs
new file mode 100644
index 00000000..ec23d0f4
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Entities/FileSystemManagement/FileSystemItemEntity.cs
@@ -0,0 +1,21 @@
+#region ========================================================================= USING =====================================================================================
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Entities.FileSystemManagement;
+
+///
+/// Generic filesystem data transfer object.
+///
+/// The path of the file system item.
+/// The name of the file system item.
+/// The creation date of the file system item.
+/// The modification date of the file system item.
+[DebuggerDisplay("Name: {Name}")]
+public record FileSystemItemEntity(
+ string Path,
+ string Name,
+ DateTime DateCreated,
+ DateTime DateModified
+);
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/MediaContributors/MediaContributorEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/MediaContributors/MediaContributorEntity.cs
new file mode 100644
index 00000000..19929100
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Entities/MediaContributors/MediaContributorEntity.cs
@@ -0,0 +1,16 @@
+#region ========================================================================= USING =====================================================================================
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Entities.MediaContributors;
+
+///
+/// Repository entity for a media contributor.
+///
+/// The name details of the media contributor, including display and legal names.
+/// The role details of the media contributor, including the role name and category.
+[DebuggerDisplay("Name: {Name}, Role: {Role}")]
+public record MediaContributorEntity(
+ MediaContributorNameEntity? Name,
+ MediaContributorRoleEntity? Role
+);
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/MediaContributors/MediaContributorNameEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/MediaContributors/MediaContributorNameEntity.cs
new file mode 100644
index 00000000..b454b894
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Entities/MediaContributors/MediaContributorNameEntity.cs
@@ -0,0 +1,16 @@
+#region ========================================================================= USING =====================================================================================
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Entities.MediaContributors;
+
+///
+/// Repository entity for a media contributor name.
+///
+/// The display name of the media contributor.
+/// The legal name of the media contributor.
+[DebuggerDisplay("DisplayName: {DisplayName}")]
+public record MediaContributorNameEntity(
+ string? DisplayName,
+ string? LegalName
+);
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/MediaContributors/MediaContributorRoleEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/MediaContributors/MediaContributorRoleEntity.cs
new file mode 100644
index 00000000..f718f6cd
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Entities/MediaContributors/MediaContributorRoleEntity.cs
@@ -0,0 +1,16 @@
+#region ========================================================================= USING =====================================================================================
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Entities.MediaContributors;
+
+///
+/// Repository entity for a media contributor role.
+///
+/// The name of the role assigned to the media contributor.
+/// The category of the role.
+[DebuggerDisplay("Name: {Name}, Category: {Category}")]
+public record MediaContributorRoleEntity(
+ string? Name,
+ string? Category
+);
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryContentLocationEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryContentLocationEntity.cs
new file mode 100644
index 00000000..c4c6a8d3
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryContentLocationEntity.cs
@@ -0,0 +1,17 @@
+#region ========================================================================= USING =====================================================================================
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
+
+///
+/// Repository entity for a media library content location.
+///
+[DebuggerDisplay("Path: {Path}")]
+public class LibraryContentLocationEntity
+{
+ ///
+ /// Gets or sets the path of the media library content location.
+ ///
+ public required string Path { get; set; }
+}
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryEntity.cs
new file mode 100644
index 00000000..e498b836
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryEntity.cs
@@ -0,0 +1,57 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Common;
+using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Domain.Common.Enums.MediaLibrary;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
+
+///
+/// Repository entity for a media library.
+///
+[DebuggerDisplay("Title: {Title}")]
+public class LibraryEntity : IStorageEntity
+{
+ ///
+ /// Gets the Id of the media library.
+ ///
+ public required Guid Id { get; init; }
+
+ ///
+ /// Gets the Id of the user that owns the media library.
+ ///
+ public required Guid UserId { get; init; }
+
+ ///
+ /// Gets or sets the title of the media library.
+ ///
+ public required string Title { get; set; }
+
+ ///
+ /// Gets or sets the type of the media library.
+ ///
+ public required LibraryType LibraryType { get; set; }
+
+ ///
+ /// Gets or sets the list of file system paths that make up the media library.
+ ///
+ public required ICollection ContentLocations { get; init; } = [];
+
+ ///
+ /// Gets the user that owns the media library.
+ ///
+ public UserEntity User { get; init; } = null!;
+
+ ///
+ /// Gets or sets the time and date when the entity was added.
+ ///
+ public required DateTime Created { get; set; }
+
+ ///
+ /// Gets or sets the optional time and date when the entity was updated.
+ ///
+ public DateTime? Updated { get; set; }
+}
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/BookEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/BookEntity.cs
new file mode 100644
index 00000000..8073dd34
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/BookEntity.cs
@@ -0,0 +1,207 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Common;
+using Lumina.Domain.Common.Enums.BookLibrary;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
+
+///
+/// Repository entity for a book.
+///
+[DebuggerDisplay("Title: {Title}")]
+public class BookEntity : IStorageEntity
+{
+ ///
+ /// Gets the Id of the media item.
+ ///
+ public required Guid Id { get; init; }
+
+ ///
+ /// Gets or sets the title of the media item.
+ ///
+ public required string Title { get; set; }
+
+ ///
+ /// Gets or sets the original title of the media item.
+ ///
+ public string? OriginalTitle { get; set; }
+
+ ///
+ /// Gets or sets the optional description of the media item.
+ ///
+ public string? Description { get; set; }
+
+ ///
+ /// Gets or sets the optional original release date of the media item.
+ ///
+ public DateOnly? OriginalReleaseDate { get; set; }
+
+ ///
+ /// Gets or sets the optional original release year of the media item.
+ /// This is useful when only the year of original release is known.
+ ///
+ public int? OriginalReleaseYear { get; set; }
+
+ ///
+ /// Gets or sets the optional re-release or reissue date of the media item.
+ ///
+ public DateOnly? ReReleaseDate { get; set; }
+
+ ///
+ /// Gets or sets the optional re-release or reissue year of the media item.
+ ///
+ public int? ReReleaseYear { get; set; }
+
+ ///
+ /// Gets or sets the optional country or region of release.
+ ///
+ public string? ReleaseCountry { get; set; }
+
+ ///
+ /// Gets or sets the optional release version or edition. (e.g. "Original", "Director's Cut", "2.0")
+ ///
+ public string? ReleaseVersion { get; set; }
+
+ ///
+ /// Gets or sets the ISO 639-1 two-letter language code.
+ ///
+ public string? LanguageCode { get; set; }
+
+ ///
+ /// Gets or sets the full name of the language in English.
+ ///
+ public string? LanguageName { get; set; }
+
+ ///
+ /// Gets or sets an optional native name of the language.
+ ///
+ public string? LanguageNativeName { get; set; }
+
+ ///
+ /// Gets or sets the optional ISO 639-1 two-letter original language code.
+ ///
+ public string? OriginalLanguageCode { get; set; }
+
+ ///
+ /// Gets or sets the optional full name of the original language in English.
+ ///
+ public string? OriginalLanguageName { get; set; }
+
+ ///
+ /// Gets or sets an optional native name of the original language.
+ ///
+ public string? OriginalLanguageNativeName { get; set; }
+
+ ///
+ /// Gets or sets the list of tags associated with the media item.
+ ///
+ public HashSet Tags { get; set; } = [];
+
+ ///
+ /// Gets or sets the list of genres associated with the media item.
+ ///
+ public HashSet Genres { get; set; } = [];
+
+ ///
+ /// Gets or sets the publisher of the written content.
+ ///
+ public string? Publisher { get; set; }
+
+ ///
+ /// Gets or sets the number of pages in the written content.
+ ///
+ public int? PageCount { get; set; }
+
+ ///
+ /// Gets or sets the format of the book (e.g., Hardcover, Paperback), if applicable.
+ ///
+ public BookFormat? Format { get; set; }
+
+ ///
+ /// Gets or sets the edition of the book, if applicable.
+ ///
+ public string? Edition { get; set; }
+
+ ///
+ /// Gets or sets the volume or book number in the series, if applicable.
+ ///
+ public int? VolumeNumber { get; set; }
+ // TODO: uncomment when series is implemented
+ ///
+ /// Gets or sets the series id, if the book is part of a series.
+ ///
+ //public Guid? BookSeriesId { get; set; }
+
+ ///
+ /// Gets or sets the ASIN (Amazon Standard Identification Number) of the book.
+ ///
+ public string? ASIN { get; set; }
+
+ ///
+ /// Gets or sets the Goodreads ID of the book.
+ ///
+ public string? GoodreadsId { get; set; }
+
+ ///
+ /// Gets or sets the Library of Congress Control Number (LCCN) of the book.
+ ///
+ public string? LCCN { get; set; }
+
+ ///
+ /// Gets or sets the OCLC Number (WorldCat identifier) of the book.
+ ///
+ public string? OCLCNumber { get; set; }
+
+ ///
+ /// Gets or sets the Open Library ID of the book.
+ ///
+ public string? OpenLibraryId { get; set; }
+
+ ///
+ /// Gets or sets the LibraryThing ID of the book.
+ ///
+ public string? LibraryThingId { get; set; }
+
+ ///
+ /// Gets or sets the Google Books ID of the book.
+ ///
+ public string? GoogleBooksId { get; set; }
+
+ ///
+ /// Gets or sets the Barnes & Noble ID of the book.
+ ///
+ public string? BarnesAndNobleId { get; set; } = null!;
+
+ ///
+ /// Gets or sets the Apple Books ID of the book.
+ ///
+ public string? AppleBooksId { get; set; }
+
+ ///
+ /// Gets or sets the list of ISBN (International Standard Book Number) of the book.
+ ///
+ public List ISBNs { get; set; } = [];
+
+ ///
+ /// Gets or sets the list of media contributors (actors, directors, etc) starring in this book.
+ ///
+ //public List ContributorIds { get; set; } = [];
+
+ ///
+ /// Gets or sets the list of ratings for this book.
+ ///
+ public List Ratings { get; set; } = [];
+
+ ///
+ /// Gets or sets the time and date when the entity was added.
+ ///
+ public required DateTime Created { get; set; }
+
+ ///
+ /// Gets or sets the optional time and date when the entity was updated.
+ ///
+ public DateTime? Updated { get; set; }
+}
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/BookRatingEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/BookRatingEntity.cs
new file mode 100644
index 00000000..f272b2cb
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/BookRatingEntity.cs
@@ -0,0 +1,22 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Common;
+using Lumina.Domain.Common.Enums.BookLibrary;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
+
+///
+/// Repository entity for a book rating.
+///
+/// The rating value for the book.
+/// The maximum possible rating value for the book.
+/// The source of the book rating (e.g., a specific website or platform).
+/// The number of votes that contributed to the book rating.
+[DebuggerDisplay("{Value}/{MaxValue}")]
+public record BookRatingEntity(
+ decimal? Value,
+ decimal? MaxValue,
+ BookRatingSource? Source,
+ int? VoteCount
+) : RatingEntity(Value, MaxValue, VoteCount);
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/BookSeriesEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/BookSeriesEntity.cs
new file mode 100644
index 00000000..3fbebff4
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/BookSeriesEntity.cs
@@ -0,0 +1,14 @@
+#region ========================================================================= USING =====================================================================================
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
+
+///
+/// Repository entity for book series.
+///
+/// The title of the book series.
+[DebuggerDisplay("Title: {Title}")]
+public record BookSeriesEntity(
+ string? Title
+);
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/IsbnEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/IsbnEntity.cs
new file mode 100644
index 00000000..6a235202
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/IsbnEntity.cs
@@ -0,0 +1,17 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Domain.Common.Enums.BookLibrary;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
+
+///
+/// Repository entity for ISBN information.
+///
+/// The ISBN value.
+/// The format of the ISBN (e.g., ISBN-10 or ISBN-13).
+[DebuggerDisplay("ISBN: {Value} ({Format})")]
+public record IsbnEntity(
+ string? Value,
+ IsbnFormat? Format
+);
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/UsersManagement/UserEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/UsersManagement/UserEntity.cs
new file mode 100644
index 00000000..fba2d476
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Entities/UsersManagement/UserEntity.cs
@@ -0,0 +1,71 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Common;
+using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+
+///
+/// Repository entity for a user.
+///
+[DebuggerDisplay("Username: {Username}")]
+public class UserEntity : IStorageEntity
+{
+ ///
+ /// Gets the Id of the user.
+ ///
+ public Guid Id { get; init; }
+
+ ///
+ /// Gets or sets the username of the user.
+ ///
+ public required string Username { get; set; }
+
+ ///
+ /// Gets or sets the hashed password of the user.
+ ///
+ public required string Password { get; set; }
+
+ ///
+ /// Gets or sets the temporary hashed password used in password recovery.
+ ///
+ public string? TempPassword { get; set; }
+
+ ///
+ /// Gets or sets the optional Time-based One-Time Password (TOTP) secret for two-factor authentication.
+ ///
+ public string? TotpSecret { get; set; }
+
+ ///
+ /// Gets or sets the optional token used for account verification or password reset.
+ ///
+ public string? VerificationToken { get; set; } // TODO: to be deleted, not used
+
+ ///
+ /// Gets or sets the optional date and time when the verification token was created.
+ ///
+ public DateTime? VerificationTokenCreated { get; set; } // TODO: to be deleted, not used
+
+ ///
+ /// Gets or sets the date and time when the temporary password used in password recovery was created.
+ ///
+ public DateTime? TempPasswordCreated { get; set; }
+
+ ///
+ /// Gets the collection of libraries owned by this user.
+ ///
+ public required ICollection Libraries { get; init; } = [];
+
+ ///
+ /// Gets the time and date when the entity was added.
+ ///
+ public required DateTime Created { get; set; }
+
+ ///
+ /// Gets the optional time and date when the entity was updated.
+ ///
+ public DateTime? Updated { get; set; }
+}
diff --git a/src/Lumina.Application/Common/DataAccess/Repositories/Books/IBookRepository.cs b/src/Lumina.Application/Common/DataAccess/Repositories/Books/IBookRepository.cs
index b925c108..6dbabc93 100644
--- a/src/Lumina.Application/Common/DataAccess/Repositories/Books/IBookRepository.cs
+++ b/src/Lumina.Application/Common/DataAccess/Repositories/Books/IBookRepository.cs
@@ -1,7 +1,7 @@
-#region ========================================================================= USING =====================================================================================
+#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
-using Lumina.Contracts.Models.WrittenContentLibrary.BookLibrary;
+using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
#endregion
namespace Lumina.Application.Common.DataAccess.Repositories.Books;
@@ -9,8 +9,8 @@ namespace Lumina.Application.Common.DataAccess.Repositories.Books;
///
/// Interface for the repository for books.
///
-public interface IBookRepository : IRepository,
- IInsertRepositoryAction,
- IGetAllRepositoryAction
+public interface IBookRepository : IRepository,
+ IInsertRepositoryAction,
+ IGetAllRepositoryAction
{
-}
\ No newline at end of file
+}
diff --git a/src/Lumina.Application/Common/DataAccess/Repositories/Common/Actions/IGetAllRepositoryAction.cs b/src/Lumina.Application/Common/DataAccess/Repositories/Common/Actions/IGetAllRepositoryAction.cs
index e30bbcc5..20bdc021 100644
--- a/src/Lumina.Application/Common/DataAccess/Repositories/Common/Actions/IGetAllRepositoryAction.cs
+++ b/src/Lumina.Application/Common/DataAccess/Repositories/Common/Actions/IGetAllRepositoryAction.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
-using Lumina.Contracts.Models.Common;
+using Lumina.Application.Common.DataAccess.Entities.Common;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
diff --git a/src/Lumina.Application/Common/DataAccess/Repositories/Common/Actions/IGetByIdRepositoryAction.cs b/src/Lumina.Application/Common/DataAccess/Repositories/Common/Actions/IGetByIdRepositoryAction.cs
index 7da7e057..244dc604 100644
--- a/src/Lumina.Application/Common/DataAccess/Repositories/Common/Actions/IGetByIdRepositoryAction.cs
+++ b/src/Lumina.Application/Common/DataAccess/Repositories/Common/Actions/IGetByIdRepositoryAction.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
-using Lumina.Contracts.Models.Common;
+using Lumina.Application.Common.DataAccess.Entities.Common;
using System.Threading;
using System.Threading.Tasks;
#endregion
diff --git a/src/Lumina.Application/Common/DataAccess/Repositories/Common/Actions/IInsertRepositoryAction.cs b/src/Lumina.Application/Common/DataAccess/Repositories/Common/Actions/IInsertRepositoryAction.cs
index 3772cad2..dfe43dbd 100644
--- a/src/Lumina.Application/Common/DataAccess/Repositories/Common/Actions/IInsertRepositoryAction.cs
+++ b/src/Lumina.Application/Common/DataAccess/Repositories/Common/Actions/IInsertRepositoryAction.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
-using Lumina.Contracts.Models.Common;
+using Lumina.Application.Common.DataAccess.Entities.Common;
using System.Threading;
using System.Threading.Tasks;
#endregion
diff --git a/src/Lumina.Application/Common/DataAccess/Repositories/Common/Actions/IUpdateRepositoryAction.cs b/src/Lumina.Application/Common/DataAccess/Repositories/Common/Actions/IUpdateRepositoryAction.cs
index fb315a88..06d860c1 100644
--- a/src/Lumina.Application/Common/DataAccess/Repositories/Common/Actions/IUpdateRepositoryAction.cs
+++ b/src/Lumina.Application/Common/DataAccess/Repositories/Common/Actions/IUpdateRepositoryAction.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
-using Lumina.Contracts.Models.Common;
+using Lumina.Application.Common.DataAccess.Entities.Common;
using System.Threading;
using System.Threading.Tasks;
#endregion
diff --git a/src/Lumina.Application/Common/DataAccess/Repositories/Common/Base/IRepository.cs b/src/Lumina.Application/Common/DataAccess/Repositories/Common/Base/IRepository.cs
index 4049862b..7a32a9e1 100644
--- a/src/Lumina.Application/Common/DataAccess/Repositories/Common/Base/IRepository.cs
+++ b/src/Lumina.Application/Common/DataAccess/Repositories/Common/Base/IRepository.cs
@@ -1,5 +1,7 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Contracts.Models.Common;
+using Lumina.Application.Common.DataAccess.Entities.Common;
+
+
#endregion
diff --git a/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryRepository.cs b/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryRepository.cs
new file mode 100644
index 00000000..d1e39a1b
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryRepository.cs
@@ -0,0 +1,15 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
+using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
+using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
+
+///
+/// Interface for the repository for media libraries.
+///
+public interface ILibraryRepository : IRepository,
+ IInsertRepositoryAction
+{
+}
diff --git a/src/Lumina.Application/Common/DataAccess/Repositories/Users/IUserRepository.cs b/src/Lumina.Application/Common/DataAccess/Repositories/Users/IUserRepository.cs
new file mode 100644
index 00000000..f45bf2fd
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Repositories/Users/IUserRepository.cs
@@ -0,0 +1,27 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
+using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Repositories.Users;
+
+///
+/// Interface for the repository for users.
+///
+public interface IUserRepository : IRepository,
+ IGetAllRepositoryAction,
+ IInsertRepositoryAction,
+ IUpdateRepositoryAction
+{
+ ///
+ /// Gets a username identified by from the repository, if it exists.
+ ///
+ /// The username of the user to get.
+ /// Cancellation token that can be used to stop the execution.
+ /// An containing either a if found, or an error.
+ Task> GetByUsernameAsync(string username, CancellationToken cancellationToken);
+}
diff --git a/src/Lumina.Application/Common/DependencyInjection/ApplicationLayerServices.cs b/src/Lumina.Application/Common/DependencyInjection/ApplicationLayerServices.cs
index 2c2ae7c9..905573aa 100644
--- a/src/Lumina.Application/Common/DependencyInjection/ApplicationLayerServices.cs
+++ b/src/Lumina.Application/Common/DependencyInjection/ApplicationLayerServices.cs
@@ -1,10 +1,9 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation;
using Lumina.Application.Common.Behaviors;
-using Mapster;
-using MapsterMapper;
using Mediator;
using Microsoft.Extensions.DependencyInjection;
+using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Application.Common.DependencyInjection;
@@ -12,6 +11,7 @@ namespace Lumina.Application.Common.DependencyInjection;
///
/// Contains all services of the Application layer.
///
+[ExcludeFromCodeCoverage]
public static class ApplicationLayerServices
{
///
@@ -33,12 +33,6 @@ public static class ApplicationLayerServices
// register fluent validators
services.AddValidatorsFromAssembly(typeof(ApplicationLayerServices).Assembly);
- // register mapster configs in this assembly
- TypeAdapterConfig mapsterConfig = TypeAdapterConfig.GlobalSettings;
- mapsterConfig.Scan(typeof(ApplicationLayerServices).Assembly);
- services.AddSingleton(mapsterConfig);
- services.AddScoped();
-
return services;
}
-}
\ No newline at end of file
+}
diff --git a/src/Lumina.Application/Common/Errors/Errors.Authentication.cs b/src/Lumina.Application/Common/Errors/Errors.Authentication.cs
new file mode 100644
index 00000000..a6bec2b7
--- /dev/null
+++ b/src/Lumina.Application/Common/Errors/Errors.Authentication.cs
@@ -0,0 +1,33 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+#endregion
+
+namespace Lumina.Application.Common.Errors;
+
+///
+/// Application authentication related error types.
+///
+public static partial class Errors
+{
+ public static class Authentication
+ {
+ public static Error UsernameAlreadyExists => Error.Conflict(description: nameof(UsernameAlreadyExists));
+ public static Error UsernameDoesNotExist => Error.NotFound(description: nameof(UsernameDoesNotExist));
+ public static Error UsernameCannotBeEmpty => Error.Validation(description: nameof(UsernameCannotBeEmpty));
+ public static Error TotpCannotBeEmpty => Error.Validation(description: nameof(TotpCannotBeEmpty));
+ public static Error PasswordCannotBeEmpty => Error.Validation(description: nameof(PasswordCannotBeEmpty));
+ public static Error NewPasswordCannotBeEmpty => Error.Validation(description: nameof(NewPasswordCannotBeEmpty));
+ public static Error CurrentPasswordCannotBeEmpty => Error.Validation(description: nameof(CurrentPasswordCannotBeEmpty));
+ public static Error PasswordConfirmCannotBeEmpty => Error.Validation(description: nameof(PasswordConfirmCannotBeEmpty));
+ public static Error NewPasswordConfirmCannotBeEmpty => Error.Validation(description: nameof(NewPasswordConfirmCannotBeEmpty));
+ public static Error InvalidPassword => Error.Validation(description: nameof(InvalidPassword));
+ public static Error UsernameMustBeBetween3And255CharactersLong => Error.Validation(description: nameof(UsernameMustBeBetween3And255CharactersLong));
+ public static Error InvalidUsername => Error.Validation(description: nameof(InvalidUsername));
+ public static Error PasswordsNotMatch => Error.Validation(description: nameof(PasswordsNotMatch));
+ public static Error InvalidTotpCode => Error.Validation(description: nameof(InvalidTotpCode));
+ public static Error InvalidUsernameOrPassword => Error.Failure(description: nameof(InvalidUsernameOrPassword));
+ public static Error InvalidCurrentPassword => Error.Failure(description: nameof(InvalidCurrentPassword));
+ public static Error TempPasswordExpired => Error.Failure(description: nameof(TempPasswordExpired));
+ public static Error PasswordResetAlreadyRequested => Error.Failure(description: nameof(PasswordResetAlreadyRequested));
+ }
+}
diff --git a/src/Lumina.Application/Common/Errors/Errors.Authorization.cs b/src/Lumina.Application/Common/Errors/Errors.Authorization.cs
new file mode 100644
index 00000000..842f394f
--- /dev/null
+++ b/src/Lumina.Application/Common/Errors/Errors.Authorization.cs
@@ -0,0 +1,16 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+#endregion
+
+namespace Lumina.Application.Common.Errors;
+
+///
+/// Application authorization related error types.
+///
+public static partial class Errors
+{
+ public static class Authorization
+ {
+ public static Error AdminAccountAlreadyCreated => Error.Unauthorized(description: nameof(AdminAccountAlreadyCreated));
+ }
+}
diff --git a/src/Lumina.Application/Common/Infrastructure/Authentication/IJwtTokenGenerator.cs b/src/Lumina.Application/Common/Infrastructure/Authentication/IJwtTokenGenerator.cs
new file mode 100644
index 00000000..92bad1d3
--- /dev/null
+++ b/src/Lumina.Application/Common/Infrastructure/Authentication/IJwtTokenGenerator.cs
@@ -0,0 +1,15 @@
+namespace Lumina.Application.Common.Infrastructure.Authentication;
+
+///
+/// Interface for generating JWT tokens.
+///
+public interface IJwtTokenGenerator
+{
+ ///
+ /// Generates a new JWT token.
+ ///
+ /// The id of the user for which to generate the token.
+ /// The username for which to generate the token.
+ /// The generated JWT token.
+ string GenerateToken(string id, string username);
+}
diff --git a/src/Lumina.Application/Common/Infrastructure/Authentication/IQRCodeGenerator.cs b/src/Lumina.Application/Common/Infrastructure/Authentication/IQRCodeGenerator.cs
new file mode 100644
index 00000000..43b3f53c
--- /dev/null
+++ b/src/Lumina.Application/Common/Infrastructure/Authentication/IQRCodeGenerator.cs
@@ -0,0 +1,15 @@
+namespace Lumina.Application.Common.Infrastructure.Authentication;
+
+///
+/// Interface for the service for generating QR codes for TOTP.
+///
+public interface IQRCodeGenerator
+{
+ ///
+ /// Generates a QR code Data URI for the specified TOTP secret.
+ ///
+ /// User's username or unique identifier.
+ /// The TOTP secret for which the QR code should be generated.
+ /// Data URI for the QR code.
+ string GenerateQrCodeDataUri(string username, byte[] secret);
+}
diff --git a/src/Lumina.Application/Common/Infrastructure/Authentication/ITokenGenerator.cs b/src/Lumina.Application/Common/Infrastructure/Authentication/ITokenGenerator.cs
new file mode 100644
index 00000000..2ba0f687
--- /dev/null
+++ b/src/Lumina.Application/Common/Infrastructure/Authentication/ITokenGenerator.cs
@@ -0,0 +1,13 @@
+namespace Lumina.Application.Common.Infrastructure.Authentication;
+
+///
+/// Interface for the service for generating secure tokens for accounts confirmation or recovery.
+///
+public interface ITokenGenerator
+{
+ ///
+ /// Generates a secure token.
+ ///
+ /// A secure token.
+ string GenerateToken();
+}
diff --git a/src/Lumina.Application/Common/Infrastructure/Authentication/ITotpTokenGenerator.cs b/src/Lumina.Application/Common/Infrastructure/Authentication/ITotpTokenGenerator.cs
new file mode 100644
index 00000000..7f369c12
--- /dev/null
+++ b/src/Lumina.Application/Common/Infrastructure/Authentication/ITotpTokenGenerator.cs
@@ -0,0 +1,21 @@
+namespace Lumina.Application.Common.Infrastructure.Authentication;
+
+///
+/// Interface for the service for generating and validating TOTP tokens.
+///
+public interface ITotpTokenGenerator
+{
+ ///
+ /// Generates a new TOTP secret for a user.
+ ///
+ /// The generated TOTP secret.
+ byte[] GenerateSecret();
+
+ ///
+ /// Validates a TOTP token against the stored secret.
+ ///
+ /// The user's TOTP secret.
+ /// The token to validate.
+ /// if valid, otherwise.
+ bool ValidateToken(byte[] secret, string token);
+}
diff --git a/src/Lumina.Application/Common/Infrastructure/Security/ICryptographyService.cs b/src/Lumina.Application/Common/Infrastructure/Security/ICryptographyService.cs
new file mode 100644
index 00000000..af3a41c8
--- /dev/null
+++ b/src/Lumina.Application/Common/Infrastructure/Security/ICryptographyService.cs
@@ -0,0 +1,27 @@
+#region ========================================================================= USING =====================================================================================
+using System;
+#endregion
+
+namespace Lumina.Application.Common.Infrastructure.Security;
+
+///
+/// Interface for the service for cryptographic concerns.
+///
+public interface ICryptographyService
+{
+ ///
+ /// Encrypts a plaintext string using AES encryption with a randomly generated initialization vector (IV).
+ ///
+ /// The plaintext string to encrypt.
+ /// A Base64-encoded string of the combined IV and encrypted ciphertext.
+ /// Thrown when is or empty.
+ string Encrypt(string plaintext);
+
+ ///
+ /// Decrypts a Base64-encoded string that contains both the IV and ciphertext.
+ ///
+ /// The Base64-encoded string containing both IV and ciphertext.
+ /// The decrypted plaintext string.
+ /// Thrown when is , empty, or invalid.
+ string Decrypt(string ciphertext);
+}
diff --git a/src/Lumina.Application/Common/Infrastructure/Security/IHashService.cs b/src/Lumina.Application/Common/Infrastructure/Security/IHashService.cs
new file mode 100644
index 00000000..77395c85
--- /dev/null
+++ b/src/Lumina.Application/Common/Infrastructure/Security/IHashService.cs
@@ -0,0 +1,22 @@
+namespace Lumina.Application.Common.Infrastructure.Security;
+
+///
+/// Interface for the service for hashing passwords.
+///
+public interface IHashService
+{
+ ///
+ /// Creates a hash from a string.
+ ///
+ /// The string to be hashed.
+ /// The hashed string.
+ string HashString(string password);
+
+ ///
+ /// Verifies a password against a hash.
+ ///
+ /// The string to be checked.
+ /// The hashed representation of the string to be checked.
+ /// if and the de-hashed versions of are equal, otherwise.
+ bool CheckStringAgainstHash(string password, string hashedPassword);
+}
diff --git a/src/Lumina.Application/Common/Infrastructure/Time/IDateTimeProvider.cs b/src/Lumina.Application/Common/Infrastructure/Time/IDateTimeProvider.cs
new file mode 100644
index 00000000..407b41d8
--- /dev/null
+++ b/src/Lumina.Application/Common/Infrastructure/Time/IDateTimeProvider.cs
@@ -0,0 +1,16 @@
+#region ========================================================================= USING =====================================================================================
+using System;
+#endregion
+
+namespace Lumina.Application.Common.Infrastructure.Time;
+
+///
+/// Interface for time related concerns.
+///
+public interface IDateTimeProvider
+{
+ ///
+ /// The current UTC time.
+ ///
+ DateTime UtcNow { get; }
+}
diff --git a/src/Lumina.Application/Common/Mapping/Authentication/ChangePasswordRequestMapping.cs b/src/Lumina.Application/Common/Mapping/Authentication/ChangePasswordRequestMapping.cs
new file mode 100644
index 00000000..382a96a7
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/Authentication/ChangePasswordRequestMapping.cs
@@ -0,0 +1,27 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.UsersManagement.Authentication.Commands.ChangePassword;
+using Lumina.Contracts.Requests.Authentication;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.Authentication;
+
+///
+/// Extension methods for converting .
+///
+public static class ChangePasswordRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted command.
+ public static ChangePasswordCommand ToCommand(this ChangePasswordRequest request)
+ {
+ return new ChangePasswordCommand(
+ request.Username,
+ request.CurrentPassword,
+ request.NewPassword,
+ request.NewPasswordConfirm
+ );
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/Authentication/LoginRequestMapping.cs b/src/Lumina.Application/Common/Mapping/Authentication/LoginRequestMapping.cs
new file mode 100644
index 00000000..018488d0
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/Authentication/LoginRequestMapping.cs
@@ -0,0 +1,26 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.UsersManagement.Authentication.Queries.LoginUser;
+using Lumina.Contracts.Requests.Authentication;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.Authentication;
+
+///
+/// Extension methods for converting .
+///
+public static class LoginRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted query.
+ public static LoginUserQuery ToQuery(this LoginRequest request)
+ {
+ return new LoginUserQuery(
+ request.Username,
+ request.Password,
+ request.TotpCode
+ );
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/Authentication/RecoverPasswordRequestMapping.cs b/src/Lumina.Application/Common/Mapping/Authentication/RecoverPasswordRequestMapping.cs
new file mode 100644
index 00000000..24d58a75
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/Authentication/RecoverPasswordRequestMapping.cs
@@ -0,0 +1,25 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.UsersManagement.Authentication.Commands.RecoverPassword;
+using Lumina.Contracts.Requests.Authentication;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.Authentication;
+
+///
+/// Extension methods for converting .
+///
+public static class RecoverPasswordRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted command.
+ public static RecoverPasswordCommand ToCommand(this RecoverPasswordRequest request)
+ {
+ return new RecoverPasswordCommand(
+ request.Username,
+ request.TotpCode
+ );
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/Authentication/RegistrationRequestMapping.cs b/src/Lumina.Application/Common/Mapping/Authentication/RegistrationRequestMapping.cs
new file mode 100644
index 00000000..49cdc0c9
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/Authentication/RegistrationRequestMapping.cs
@@ -0,0 +1,43 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.Maintenance.ApplicationSetup.Commands.SetupApplication;
+using Lumina.Application.Core.UsersManagement.Authentication.Commands.RegisterUser;
+using Lumina.Contracts.Requests.Authentication;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.Authentication;
+
+///
+/// Extension methods for converting .
+///
+public static class RegistrationRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted command.
+ public static SetupApplicationCommand ToSetupCommand(this RegistrationRequest request)
+ {
+ return new SetupApplicationCommand(
+ request.Username,
+ request.Password,
+ request.PasswordConfirm,
+ request.Use2fa
+ );
+ }
+
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted command.
+ public static RegisterUserCommand ToCommand(this RegistrationRequest request)
+ {
+ return new RegisterUserCommand(
+ request.Username,
+ request.Password,
+ request.PasswordConfirm,
+ request.Use2fa
+ );
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/Common/Metadata/GenreDtoMapping.cs b/src/Lumina.Application/Common/Mapping/Common/Metadata/GenreDtoMapping.cs
new file mode 100644
index 00000000..7406368b
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/Common/Metadata/GenreDtoMapping.cs
@@ -0,0 +1,37 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Contracts.DTO.Common;
+using Lumina.Domain.Common.ValueObjects.Metadata;
+using System.Collections.Generic;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.Common.Metadata;
+
+///
+/// Extension methods for converting .
+///
+public static class GenreDtoMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The DTO to be converted.
+ /// The converted domain entity.
+ public static ErrorOr ToDomainEntity(this GenreDto dto)
+ {
+ return Genre.Create(
+ dto.Name
+ );
+ }
+
+ ///
+ /// Converts to a collection of .
+ ///
+ /// The DTOs to be converted.
+ /// The converted domain entities.
+ public static IEnumerable> ToDomainEntities(this IEnumerable dtos)
+ {
+ return dtos.Select(repositoryEntity => repositoryEntity.ToDomainEntity());
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/Common/Metadata/GenreEntityMapping.cs b/src/Lumina.Application/Common/Mapping/Common/Metadata/GenreEntityMapping.cs
new file mode 100644
index 00000000..b2aa43fc
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/Common/Metadata/GenreEntityMapping.cs
@@ -0,0 +1,60 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Application.Common.DataAccess.Entities.Common;
+using Lumina.Contracts.DTO.Common;
+using Lumina.Domain.Common.ValueObjects.Metadata;
+using System.Collections.Generic;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.Common.Metadata;
+
+///
+/// Extension methods for converting .
+///
+public static class GenreEntityMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The repository entity to be converted.
+ /// The converted DTO.
+ public static GenreDto ToResponse(this GenreEntity repositoryEntity)
+ {
+ return new GenreDto(
+ repositoryEntity.Name ?? default
+ );
+ }
+
+ ///
+ /// Converts to a collection of .
+ ///
+ /// The repository entities to be converted.
+ /// The converted DTOs.
+ public static IEnumerable ToResponses(this IEnumerable repositoryEntities)
+ {
+ return repositoryEntities.Select(responseEntity => responseEntity.ToResponse());
+ }
+
+ ///
+ /// Converts to .
+ ///
+ /// The repository entity to be converted.
+ /// The converted domain entity.
+ public static ErrorOr ToDomainEntity(this GenreEntity repositoryEntity)
+ {
+ return Genre.Create(
+ repositoryEntity.Name ?? default
+ );
+ }
+
+ ///
+ /// Converts to a collection of .
+ ///
+ /// The repository entities to be converted.
+ /// The converted domain entities.
+ public static IEnumerable> ToDomainEntities(this IEnumerable repositoryEntities)
+ {
+ return repositoryEntities.Select(domainEntity => domainEntity.ToDomainEntity());
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/Common/Metadata/GenreMapping.cs b/src/Lumina.Application/Common/Mapping/Common/Metadata/GenreMapping.cs
new file mode 100644
index 00000000..be53f39d
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/Common/Metadata/GenreMapping.cs
@@ -0,0 +1,36 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Common;
+using Lumina.Domain.Common.ValueObjects.Metadata;
+using System.Collections.Generic;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.Common.Metadata;
+
+///
+/// Extension methods for converting .
+///
+public static class GenreMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The domain entity to be converted.
+ /// The converted repository entity.
+ public static GenreEntity ToRepositoryEntity(this Genre domainEntity)
+ {
+ return new GenreEntity(
+ domainEntity.Name
+ );
+ }
+
+ ///
+ /// Converts to a collection of .
+ ///
+ /// The domain entities to be converted.
+ /// The converted repository entities.
+ public static IEnumerable ToRepositoryEntities(this IEnumerable domainEntities)
+ {
+ return domainEntities.Select(domainEntity => domainEntity.ToRepositoryEntity());
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/Common/Metadata/TagDtoMapping.cs b/src/Lumina.Application/Common/Mapping/Common/Metadata/TagDtoMapping.cs
new file mode 100644
index 00000000..d16b750f
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/Common/Metadata/TagDtoMapping.cs
@@ -0,0 +1,37 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Contracts.DTO.Common;
+using Lumina.Domain.Common.ValueObjects.Metadata;
+using System.Collections.Generic;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.Common.Metadata;
+
+///
+/// Extension methods for converting .
+///
+public static class TagDtoMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The DTO to be converted.
+ /// The converted domain entity.
+ public static ErrorOr ToDomainEntity(this TagDto dto)
+ {
+ return Tag.Create(
+ dto.Name
+ );
+ }
+
+ ///
+ /// Converts to a collection of .
+ ///
+ /// The DTOs to be converted.
+ /// The converted domain entities.
+ public static IEnumerable> ToDomainEntities(this IEnumerable dtos)
+ {
+ return dtos.Select(domainEntity => domainEntity.ToDomainEntity());
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/Common/Metadata/TagEntityMapping.cs b/src/Lumina.Application/Common/Mapping/Common/Metadata/TagEntityMapping.cs
new file mode 100644
index 00000000..802ef48d
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/Common/Metadata/TagEntityMapping.cs
@@ -0,0 +1,60 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Application.Common.DataAccess.Entities.Common;
+using Lumina.Contracts.DTO.Common;
+using Lumina.Domain.Common.ValueObjects.Metadata;
+using System.Collections.Generic;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.Common.Metadata;
+
+///
+/// Extension methods for converting .
+///
+public static class TagEntityMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The repository entity to be converted.
+ /// The converted DTO.
+ public static TagDto ToResponse(this TagEntity repositoryEntity)
+ {
+ return new TagDto(
+ repositoryEntity.Name ?? default
+ );
+ }
+
+ ///
+ /// Converts to a collection of .
+ ///
+ /// The repository entities to be converted.
+ /// The converted DTOs.
+ public static IEnumerable ToResponses(this IEnumerable repositoryEntities)
+ {
+ return repositoryEntities.Select(responseEntity => responseEntity.ToResponse());
+ }
+
+ ///
+ /// Converts to .
+ ///
+ /// The repository entity to be converted.
+ /// The converted domain entity.
+ public static ErrorOr ToDomainEntity(this TagEntity repositoryEntity)
+ {
+ return Tag.Create(
+ repositoryEntity.Name ?? default
+ );
+ }
+
+ ///
+ /// Converts to a collection of .
+ ///
+ /// The repository entities to be converted.
+ /// The converted domain entities.
+ public static IEnumerable> ToDomainEntities(this IEnumerable repositoryEntities)
+ {
+ return repositoryEntities.Select(domainEntity => domainEntity.ToDomainEntity());
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/Common/Metadata/TagMapping.cs b/src/Lumina.Application/Common/Mapping/Common/Metadata/TagMapping.cs
new file mode 100644
index 00000000..de4d79f7
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/Common/Metadata/TagMapping.cs
@@ -0,0 +1,36 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Common;
+using Lumina.Domain.Common.ValueObjects.Metadata;
+using System.Collections.Generic;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.Common.Metadata;
+
+///
+/// Extension methods for converting .
+///
+public static class TagMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The domain entity to be converted.
+ /// The converted repository entity.
+ public static TagEntity ToRepositoryEntity(this Tag domainEntity)
+ {
+ return new TagEntity(
+ domainEntity.Name
+ );
+ }
+
+ ///
+ /// Converts to a collection of .
+ ///
+ /// The domain entity to be converted.
+ /// The converted repository entities.
+ public static IEnumerable ToRepositoryEntities(this IEnumerable domainEntities)
+ {
+ return domainEntities.Select(domainEntity => domainEntity.ToRepositoryEntity());
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/FileManagement/DirectoryMappingConfig.cs b/src/Lumina.Application/Common/Mapping/FileManagement/DirectoryMappingConfig.cs
deleted file mode 100644
index f06995e5..00000000
--- a/src/Lumina.Application/Common/Mapping/FileManagement/DirectoryMappingConfig.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-#region ========================================================================= USING =====================================================================================
-using Lumina.Contracts.Models.FileManagement;
-using Lumina.Contracts.Responses.FileManagement;
-using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate;
-using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
-using Mapster;
-using System;
-using System.Collections.Generic;
-#endregion
-
-namespace Lumina.Application.Common.Mapping.FileManagement;
-
-///
-/// Mapping configuration for file system directories between the domain object and the presentation object.
-///
-public class DirectoryMappingConfig : IRegister
-{
- ///
- /// Registers the mapping configuration.
- ///
- /// The type adapter configuration.
- public void Register(TypeAdapterConfig config)
- {
- config.NewConfig()
- .Map(dest => dest.Name, src => src.Name)
- .Map(dest => dest.Path, src => src.Id.Path)
- .Map(dest => dest.ItemType, src => src.Type)
- .Map(dest => dest.IsExpanded, () => false)
- .Map(dest => dest.ChildrenLoaded, () => false)
- .Map(dest => dest.Children, src => src.Items.Adapt>())
- .MapToConstructor(true);
-
- config.NewConfig()
- .MapWith(src => new DirectoryResponse(
- src.Id.Path,
- src.Name,
- src.DateCreated.Value,
- src.DateModified.Value,
- src.Items.Adapt>()
- ));
-
- config.NewConfig()
- .MapWith(src => new FileSystemItemModel(
- src.Id.Path,
- src.Name,
- DateTime.Now,
- DateTime.Now
- ));
- }
-}
diff --git a/src/Lumina.Application/Common/Mapping/FileManagement/FileMappingConfig.cs b/src/Lumina.Application/Common/Mapping/FileManagement/FileMappingConfig.cs
deleted file mode 100644
index 1af19c28..00000000
--- a/src/Lumina.Application/Common/Mapping/FileManagement/FileMappingConfig.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-#region ========================================================================= USING =====================================================================================
-using Lumina.Contracts.Responses.FileManagement;
-using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
-using Mapster;
-#endregion
-
-namespace Lumina.Application.Common.Mapping.FileManagement;
-
-///
-/// Mapping configuration for file system files between the domain object and the presentation object.
-///
-public class FileMappingConfig : IRegister
-{
- ///
- /// Registers the mapping configuration.
- ///
- /// The type adapter configuration.
- public void Register(TypeAdapterConfig config)
- {
- config.NewConfig()
- .Map(dest => dest.Name, src => src.Name)
- .Map(dest => dest.Path, src => src.Id.Path)
- .Map(dest => dest.ItemType, src => src.Type)
- .Map(dest => dest.IsExpanded, () => false)
- .Map(dest => dest.ChildrenLoaded, () => false)
- .MapToConstructor(true);
-
- config.NewConfig()
- .MapWith(src => new FileResponse(
- src.Id.Path,
- src.Name,
- src.DateCreated.HasValue ? src.DateCreated.Value : default,
- src.DateModified.HasValue ? src.DateModified.Value : default,
- src.Size
- ));
- }
-}
\ No newline at end of file
diff --git a/src/Lumina.Application/Common/Mapping/FileManagement/FileSystemTreeMappingConfig.cs b/src/Lumina.Application/Common/Mapping/FileManagement/FileSystemTreeMappingConfig.cs
deleted file mode 100644
index bde5226f..00000000
--- a/src/Lumina.Application/Common/Mapping/FileManagement/FileSystemTreeMappingConfig.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-#region ========================================================================= USING =====================================================================================
-using Lumina.Contracts.Enums.FileSystem;
-using Lumina.Contracts.Responses.FileManagement;
-using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate;
-using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
-using Mapster;
-using System.Collections.Generic;
-using System.Linq;
-#endregion
-
-namespace Lumina.Application.Common.Mapping.FileManagement;
-
-///
-/// Mapping configuration for file system trees between the domain object and the presentation object.
-///
-public class FileSystemTreeMappingConfig : IRegister
-{
- ///
- /// Registers the mapping configuration.
- ///
- /// The type adapter configuration.
- public void Register(TypeAdapterConfig config)
- {
- config.NewConfig()
- .Map(dest => dest.Path, src => src.Id.Path)
- .Map(dest => dest.Name, src => src.Name)
- .Map(dest => dest.ItemType, src => FileSystemItemType.Root)
- .Map(dest => dest.IsExpanded, () => false);
-
- config.NewConfig()
- .MapWith(src => WindowsRootItem.Create(
- src.Path,
- src.Name,
- FileSystemItemStatus.Accessible)
- .Value);
-
- config.NewConfig()
- .Map(dest => dest.Path, src => src.Id.Path)
- .Map(dest => dest.Name, src => src.Name)
- .Map(dest => dest.ItemType, src => FileSystemItemType.Root)
- .Map(dest => dest.IsExpanded, () => false)
- .Map(dest => dest.ChildrenLoaded, () => false)
- .Map(dest => dest.Children, src => src.Items.Select(item => item.Adapt(config)).ToList());
-
- config.NewConfig()
- .MapWith(src => UnixRootItem.Create(
- FileSystemItemStatus.Accessible)
- .Value);
-
- config.NewConfig()
- .Map(dest => dest.Name, src => src.Name)
- .Map(dest => dest.Path, src => src.Id.Path)
- .Map(dest => dest.ItemType, src => src.Type)
- .Map(dest => dest.IsExpanded, _ => false)
- .Map(dest => dest.ChildrenLoaded, _ => false)
- .Map(dest => dest.ChildrenLoaded, _ => false)
- .AfterMapping((src, dest) =>
- {
- if (src is Directory dir)
- dest.Children = dir.Items.Select(item => item.Adapt(config)).ToList();
- else
- dest.Children = [];
- });
- }
-}
diff --git a/src/Lumina.Application/Common/Mapping/FileManagement/PathSegmentMappingConfig.cs b/src/Lumina.Application/Common/Mapping/FileManagement/PathSegmentMappingConfig.cs
deleted file mode 100644
index bdf17a9c..00000000
--- a/src/Lumina.Application/Common/Mapping/FileManagement/PathSegmentMappingConfig.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-#region ========================================================================= USING =====================================================================================
-using Lumina.Contracts.Responses.FileManagement;
-using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
-using Mapster;
-#endregion
-
-namespace Lumina.Application.Common.Mapping.FileManagement;
-
-///
-/// Mapping configuration for file system paths between the domain object and the presentation object.
-///
-public class PathSegmentMappingConfig : IRegister
-{
- ///
- /// Registers the mapping configuration.
- ///
- /// The type adapter configuration.
- public void Register(TypeAdapterConfig config)
- {
- config.NewConfig()
- .Map(dest => dest.Path, src => src.Name)
- .MapToConstructor(true);
- }
-}
\ No newline at end of file
diff --git a/src/Lumina.Application/Common/Mapping/FileManagement/ThumbnailMappingConfig.cs b/src/Lumina.Application/Common/Mapping/FileManagement/ThumbnailMappingConfig.cs
deleted file mode 100644
index d51d97ed..00000000
--- a/src/Lumina.Application/Common/Mapping/FileManagement/ThumbnailMappingConfig.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-#region ========================================================================= USING =====================================================================================
-using Lumina.Contracts.Responses.FileManagement;
-using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
-using Mapster;
-#endregion
-
-namespace Lumina.Application.Common.Mapping.FileManagement;
-
-///
-/// Mapping configuration for file system thumbnails between the domain object and the presentation object.
-///
-public class ThumbnailMappingConfig : IRegister
-{
- ///
- /// Registers the mapping configuration.
- ///
- /// The type adapter configuration.
- public void Register(TypeAdapterConfig config)
- {
- config.NewConfig()
- .Map(dest => dest.Type, src => src.Type)
- .Map(dest => dest.Bytes, src => src.Bytes)
- .MapToConstructor(true);
- }
-}
diff --git a/src/Lumina.Application/Common/Mapping/FileSystemManagement/Common/FileSystemTreeNodeResponseMapping.cs b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Common/FileSystemTreeNodeResponseMapping.cs
new file mode 100644
index 00000000..ce65db5c
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Common/FileSystemTreeNodeResponseMapping.cs
@@ -0,0 +1,40 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Domain.Common.Enums.FileSystem;
+using Lumina.Contracts.Responses.FileSystemManagement.Common;
+using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.FileSystemManagement.Common;
+
+///
+/// Extension methods for converting .
+///
+public static class FileSystemTreeNodeResponseMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The response to be converted.
+ /// The converted domain entity.
+ public static ErrorOr ToWindowsRootItem(this FileSystemTreeNodeResponse response)
+ {
+ return WindowsRootItem.Create(
+ response.Path,
+ response.Name,
+ FileSystemItemStatus.Accessible
+ );
+ }
+
+ ///
+ /// Converts to .
+ ///
+ /// The response to be converted.
+ /// The converted domain entity.
+ public static ErrorOr ToUnixRootItem(this FileSystemTreeNodeResponse _)
+ {
+ return UnixRootItem.Create(
+ FileSystemItemStatus.Accessible
+ );
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/FileSystemManagement/Directories/DirectoryMapping.cs b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Directories/DirectoryMapping.cs
new file mode 100644
index 00000000..35f4b8d4
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Directories/DirectoryMapping.cs
@@ -0,0 +1,72 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.Mapping.FileSystemManagement.FileSystem;
+using Lumina.Contracts.Responses.FileSystemManagement.Common;
+using Lumina.Contracts.Responses.FileSystemManagement.Directories;
+using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
+using System.Collections.Generic;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.FileSystemManagement.Directories;
+
+///
+/// Extension methods for converting .
+///
+public static class DirectoryMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The domain entity to be converted.
+ /// The converted response.
+ public static FileSystemTreeNodeResponse ToFileSystemTreeNodeResponse(this Directory domainEntity)
+ {
+ return new FileSystemTreeNodeResponse()
+ {
+ Name = domainEntity.Name,
+ Path = domainEntity.Id.Path,
+ ItemType = domainEntity.Type,
+ IsExpanded = false,
+ ChildrenLoaded = false,
+ Children = domainEntity.Items.Select(item => item.ToTreeNodeResponse())
+ .ToList()
+ };
+ }
+
+ ///
+ /// Converts to a collection of .
+ ///
+ /// The domain entities to be converted.
+ /// The converted responses.
+ public static IEnumerable ToFileSystemTreeNodeResponses(this IEnumerable domainEntities)
+ {
+ return domainEntities.Select(domainEntity => domainEntity.ToTreeNodeResponse());
+ }
+
+ ///
+ /// Converts to .
+ ///
+ /// The domain entity to be converted.
+ /// The converted response.
+ public static DirectoryResponse ToResponse(this Directory domainEntity)
+ {
+ return new DirectoryResponse(
+ domainEntity.Id.Path,
+ domainEntity.Name,
+ domainEntity.DateCreated.Value,
+ domainEntity.DateModified.Value,
+ domainEntity.Items.Select(fileSystemItem => fileSystemItem.ToFileSystemItemDto())
+ .ToList()
+ );
+ }
+
+ ///
+ /// Converts to a collection of .
+ ///
+ /// The domain entities to be converted.
+ /// The converted responses.
+ public static IEnumerable ToResponses(this IEnumerable domainEntities)
+ {
+ return domainEntities.Select(domainEntity => domainEntity.ToResponse());
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/FileSystemManagement/Directories/GetDirectoriesRequestMapping.cs b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Directories/GetDirectoriesRequestMapping.cs
new file mode 100644
index 00000000..b57de0a7
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Directories/GetDirectoriesRequestMapping.cs
@@ -0,0 +1,22 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetDirectories;
+using Lumina.Contracts.Requests.FileSystemManagement.Directories;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.FileSystemManagement.Directories;
+
+///
+/// Extension methods for converting .
+///
+public static class GetDirectoriesRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted query.
+ public static GetDirectoriesQuery ToQuery(this GetDirectoriesRequest request)
+ {
+ return new GetDirectoriesQuery(request.Path, request.IncludeHiddenElements);
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/FileSystemManagement/Directories/GetDirectoryTreeRequestMapping.cs b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Directories/GetDirectoryTreeRequestMapping.cs
new file mode 100644
index 00000000..8326966b
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Directories/GetDirectoryTreeRequestMapping.cs
@@ -0,0 +1,22 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetDirectoryTree;
+using Lumina.Contracts.Requests.FileSystemManagement.Directories;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.FileSystemManagement.Directories;
+
+///
+/// Extension methods for converting .
+///
+public static class GetDirectoryTreeRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted query.
+ public static GetDirectoryTreeQuery ToQuery(this GetDirectoryTreeRequest request)
+ {
+ return new GetDirectoryTreeQuery(request.Path, request.IncludeFiles, request.IncludeHiddenElements);
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/FileSystemManagement/Directories/GetTreeDirectoriesRequestMapping.cs b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Directories/GetTreeDirectoriesRequestMapping.cs
new file mode 100644
index 00000000..ba826c6a
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Directories/GetTreeDirectoriesRequestMapping.cs
@@ -0,0 +1,22 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetTreeDirectories;
+using Lumina.Contracts.Requests.FileSystemManagement.Directories;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.FileSystemManagement.Directories;
+
+///
+/// Extension methods for converting .
+///
+public static class GetTreeDirectoriesRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted query.
+ public static GetTreeDirectoriesQuery ToQuery(this GetTreeDirectoriesRequest request)
+ {
+ return new GetTreeDirectoriesQuery(request.Path, request.IncludeHiddenElements);
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/FileSystemManagement/FileSystem/FileSystemItemMapping.cs b/src/Lumina.Application/Common/Mapping/FileSystemManagement/FileSystem/FileSystemItemMapping.cs
new file mode 100644
index 00000000..7149ecc5
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/FileSystemManagement/FileSystem/FileSystemItemMapping.cs
@@ -0,0 +1,64 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.Mapping.FileSystemManagement.Directories;
+using Lumina.Application.Common.Mapping.FileSystemManagement.Files;
+using Lumina.Contracts.Responses.FileSystemManagement.Common;
+using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
+using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Lumina.Contracts.DTO.FileSystemManagement;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.FileSystemManagement.FileSystem;
+
+///
+/// Extension methods for converting .
+///
+public static class FileSystemItemMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The domain entity to be converted.
+ /// The converted Dto.
+ public static FileSystemItemDto ToFileSystemItemDto(this FileSystemItem domainEntity)
+ {
+ return new FileSystemItemDto(
+ domainEntity.Id.Path,
+ domainEntity.Name,
+ DateTime.Now,
+ DateTime.Now
+ );
+ }
+
+ ///
+ /// Converts to .
+ ///
+ /// The domain entity to be converted.
+ /// The converted entity.
+ /// Thrown when the provided parameter is not an expected descendant of .
+ public static FileSystemTreeNodeResponse ToTreeNodeResponse(this FileSystemItem domainEntity)
+ {
+ if (domainEntity is Directory directory)
+ return directory.ToFileSystemTreeNodeResponse();
+ else if (domainEntity is File file)
+ return file.ToFileSystemTreeNodeResponse();
+ else if (domainEntity is WindowsRootItem windowsRootItem)
+ return windowsRootItem.ToTreeNodeResponse();
+ else if (domainEntity is UnixRootItem unixRootItem)
+ return unixRootItem.ToTreeNodeResponse();
+ else
+ throw new ArgumentException("Invalid FileSystemItem");
+ }
+
+ ///
+ /// Converts to .
+ ///
+ /// The domain entities to be converted.
+ /// The converted entities.
+ public static IEnumerable ToTreeNodeResponses(this IEnumerable domainEntities)
+ {
+ return domainEntities.Select(domainEntity => domainEntity.ToTreeNodeResponse());
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/FileSystemManagement/FileSystem/UnixRootItemMapping.cs b/src/Lumina.Application/Common/Mapping/FileSystemManagement/FileSystem/UnixRootItemMapping.cs
new file mode 100644
index 00000000..ade9cffa
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/FileSystemManagement/FileSystem/UnixRootItemMapping.cs
@@ -0,0 +1,33 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Domain.Common.Enums.FileSystem;
+using Lumina.Contracts.Responses.FileSystemManagement.Common;
+using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.FileSystemManagement.FileSystem;
+
+///
+/// Extension methods for converting .
+///
+public static class UnixRootItemMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The domain entity to be converted.
+ /// The converted response.
+ public static FileSystemTreeNodeResponse ToTreeNodeResponse(this UnixRootItem domainEntity)
+ {
+ return new FileSystemTreeNodeResponse()
+ {
+ Path = domainEntity.Id.Path,
+ Name = domainEntity.Name,
+ ItemType = FileSystemItemType.Root,
+ IsExpanded = false,
+ ChildrenLoaded = false,
+ Children = domainEntity.Items.Select(item => item.ToTreeNodeResponse())
+ .ToList()
+ };
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/FileSystemManagement/FileSystem/WindowsRootItemMapping.cs b/src/Lumina.Application/Common/Mapping/FileSystemManagement/FileSystem/WindowsRootItemMapping.cs
new file mode 100644
index 00000000..68666b1d
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/FileSystemManagement/FileSystem/WindowsRootItemMapping.cs
@@ -0,0 +1,29 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Domain.Common.Enums.FileSystem;
+using Lumina.Contracts.Responses.FileSystemManagement.Common;
+using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.FileSystemManagement.FileSystem;
+
+///
+/// Extension methods for converting .
+///
+public static class WindowsRootItemMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The domain entity to be converted.
+ /// The converted response.
+ public static FileSystemTreeNodeResponse ToTreeNodeResponse(this WindowsRootItem domainEntity)
+ {
+ return new FileSystemTreeNodeResponse()
+ {
+ Path = domainEntity.Id.Path,
+ Name = domainEntity.Name,
+ ItemType = FileSystemItemType.Root,
+ IsExpanded = false
+ };
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/FileSystemManagement/Files/FileMapping.cs b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Files/FileMapping.cs
new file mode 100644
index 00000000..a128da91
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Files/FileMapping.cs
@@ -0,0 +1,68 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Contracts.Responses.FileSystemManagement.Common;
+using Lumina.Contracts.Responses.FileSystemManagement.Files;
+using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
+using System.Collections.Generic;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.FileSystemManagement.Files;
+
+///
+/// Extension methods for converting .
+///
+public static class FileMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The domain entity to be converted.
+ /// The converted response.
+ public static FileSystemTreeNodeResponse ToFileSystemTreeNodeResponse(this File domainEntity)
+ {
+ return new FileSystemTreeNodeResponse()
+ {
+ Name = domainEntity.Name,
+ Path = domainEntity.Id.Path,
+ ItemType = domainEntity.Type,
+ IsExpanded = false,
+ ChildrenLoaded = false
+ };
+ }
+
+ ///
+ /// Converts to a collection of .
+ ///
+ /// The domain entities to be converted.
+ /// The converted responses.
+ public static IEnumerable ToFileSystemTreeNodeResponses(this IEnumerable domainEntities)
+ {
+ return domainEntities.Select(domainEntity => domainEntity.ToFileSystemTreeNodeResponse());
+ }
+
+ ///
+ /// Converts to .
+ ///
+ /// The domain entity to be converted.
+ /// The converted response.
+ public static FileResponse ToResponse(this File domainEntity)
+ {
+ return new FileResponse(
+ domainEntity.Id.Path,
+ domainEntity.Name,
+ domainEntity.DateCreated.HasValue ? domainEntity.DateCreated.Value : default,
+ domainEntity.DateModified.HasValue ? domainEntity.DateModified.Value : default,
+ domainEntity.Size
+ );
+ }
+
+ ///
+ /// Converts to a collection of .
+ ///
+ /// The domain entities to be converted.
+ /// The converted responses.
+ public static IEnumerable ToResponses(this IEnumerable domainEntities)
+ {
+ return domainEntities.Select(domainEntity => domainEntity.ToResponse());
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/FileSystemManagement/Files/GetFilesRequestMapping.cs b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Files/GetFilesRequestMapping.cs
new file mode 100644
index 00000000..76bda209
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Files/GetFilesRequestMapping.cs
@@ -0,0 +1,22 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.FileSystemManagement.Files.Queries.GetFiles;
+using Lumina.Contracts.Requests.FileSystemManagement.Files;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.FileSystemManagement.Files;
+
+///
+/// Extension methods for converting .
+///
+public static class GetFilesRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted query.
+ public static GetFilesQuery ToQuery(this GetFilesRequest request)
+ {
+ return new GetFilesQuery(request.Path, request.IncludeHiddenElements);
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/FileSystemManagement/Files/GetTreeFilesRequestMapping.cs b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Files/GetTreeFilesRequestMapping.cs
new file mode 100644
index 00000000..1ab64057
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Files/GetTreeFilesRequestMapping.cs
@@ -0,0 +1,23 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetTreeDirectories;
+using Lumina.Application.Core.FileSystemManagement.Files.Queries.GetTreeFiles;
+using Lumina.Contracts.Requests.FileSystemManagement.Files;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.FileSystemManagement.Files;
+
+///
+/// Extension methods for converting .
+///
+public static class GetTreeFilesRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted query.
+ public static GetTreeFilesQuery ToQuery(this GetTreeFilesRequest request)
+ {
+ return new GetTreeFilesQuery(request.Path, request.IncludeHiddenElements);
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/FileSystemManagement/Paths/CheckPathExistsRequestMapping.cs b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Paths/CheckPathExistsRequestMapping.cs
new file mode 100644
index 00000000..d34f0eb2
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Paths/CheckPathExistsRequestMapping.cs
@@ -0,0 +1,25 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.FileSystemManagement.Paths.Queries.CheckPathExists;
+using Lumina.Contracts.Requests.FileSystemManagement.Path;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
+
+///
+/// Extension methods for converting .
+///
+public static class CheckPathExistsRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted query.
+ public static CheckPathExistsQuery ToQuery(this CheckPathExistsRequest request)
+ {
+ return new CheckPathExistsQuery(
+ request.Path,
+ request.IncludeHiddenElements
+ );
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/FileSystemManagement/Paths/CombinePathRequestMapping.cs b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Paths/CombinePathRequestMapping.cs
new file mode 100644
index 00000000..0078aadb
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Paths/CombinePathRequestMapping.cs
@@ -0,0 +1,25 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.FileSystemManagement.Paths.Commands.CombinePath;
+using Lumina.Contracts.Requests.FileSystemManagement.Path;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
+
+///
+/// Extension methods for converting .
+///
+public static class CombinePathRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted command.
+ public static CombinePathCommand ToCommand(this CombinePathRequest request)
+ {
+ return new CombinePathCommand(
+ request.OriginalPath,
+ request.NewPath
+ );
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/FileSystemManagement/Paths/GetPathParentRequestMapping.cs b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Paths/GetPathParentRequestMapping.cs
new file mode 100644
index 00000000..121e5dad
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Paths/GetPathParentRequestMapping.cs
@@ -0,0 +1,24 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathParent;
+using Lumina.Contracts.Requests.FileSystemManagement.Path;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
+
+///
+/// Extension methods for converting .
+///
+public static class GetPathParentRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted query.
+ public static GetPathParentQuery ToQuery(this GetPathParentRequest request)
+ {
+ return new GetPathParentQuery(
+ request.Path
+ );
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/FileSystemManagement/Paths/GetPathRootRequestMapping.cs b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Paths/GetPathRootRequestMapping.cs
new file mode 100644
index 00000000..a6538eed
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Paths/GetPathRootRequestMapping.cs
@@ -0,0 +1,22 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathRoot;
+using Lumina.Contracts.Requests.FileSystemManagement.Path;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
+
+///
+/// Extension methods for converting .
+///
+public static class GetPathRootRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted query.
+ public static GetPathRootQuery ToQuery(this GetPathRootRequest request)
+ {
+ return new GetPathRootQuery(request.Path);
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/FileSystemManagement/Paths/PathSegmentMapping.cs b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Paths/PathSegmentMapping.cs
new file mode 100644
index 00000000..02a24842
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Paths/PathSegmentMapping.cs
@@ -0,0 +1,36 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Contracts.Responses.FileSystemManagement.Path;
+using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
+using System.Collections.Generic;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
+
+///
+/// Extension methods for converting .
+///
+public static class PathSegmentMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The domain entity to be converted.
+ /// The converted response.
+ public static PathSegmentResponse ToResponse(this PathSegment domainEntity)
+ {
+ return new PathSegmentResponse(
+ domainEntity.Name
+ );
+ }
+
+ ///
+ /// Converts to a collection of .
+ ///
+ /// The domain entities to be converted.
+ /// The converted responses.
+ public static IEnumerable ToResponses(this IEnumerable domainEntities)
+ {
+ return domainEntities.Select(domainEntity => domainEntity.ToResponse());
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/FileSystemManagement/Paths/SplitPathRequestMapping.cs b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Paths/SplitPathRequestMapping.cs
new file mode 100644
index 00000000..1d44cd1d
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Paths/SplitPathRequestMapping.cs
@@ -0,0 +1,24 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.FileSystemManagement.Paths.Commands.SplitPath;
+using Lumina.Contracts.Requests.FileSystemManagement.Path;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
+
+///
+/// Extension methods for converting .
+///
+public static class SplitPathRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted command.
+ public static SplitPathCommand ToCommand(this SplitPathRequest request)
+ {
+ return new SplitPathCommand(
+ request.Path
+ );
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/FileSystemManagement/Paths/ValidatePathRequestMapping.cs b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Paths/ValidatePathRequestMapping.cs
new file mode 100644
index 00000000..ac918191
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Paths/ValidatePathRequestMapping.cs
@@ -0,0 +1,24 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.FileSystemManagement.Paths.Queries.ValidatePath;
+using Lumina.Contracts.Requests.FileSystemManagement.Path;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
+
+///
+/// Extension methods for converting .
+///
+public static class ValidatePathRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted query.
+ public static ValidatePathQuery ToQuery(this ValidatePathRequest request)
+ {
+ return new ValidatePathQuery(
+ request.Path
+ );
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/FileSystemManagement/Thumbnails/GetThumbnailRequestMapping.cs b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Thumbnails/GetThumbnailRequestMapping.cs
new file mode 100644
index 00000000..8fa534eb
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Thumbnails/GetThumbnailRequestMapping.cs
@@ -0,0 +1,22 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.FileSystemManagement.Thumbnails.Queries.GetThumbnail;
+using Lumina.Contracts.Requests.FileSystemManagement.Thumbnails;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.FileSystemManagement.Thumbnails;
+
+///
+/// Extension methods for converting .
+///
+public static class GetThumbnailRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted query.
+ public static GetThumbnailQuery ToQuery(this GetThumbnailRequest request)
+ {
+ return new GetThumbnailQuery(request.Path, request.Quality);
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/FileSystemManagement/Thumbnails/ThumbnailMapping.cs b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Thumbnails/ThumbnailMapping.cs
new file mode 100644
index 00000000..bd010de0
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Thumbnails/ThumbnailMapping.cs
@@ -0,0 +1,25 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Contracts.Responses.FileSystemManagement.Thumbnails;
+using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.FileSystemManagement.Thumbnails;
+
+///
+/// Extension methods for converting .
+///
+public static class ThumbnailMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The domain entity to be converted.
+ /// The converted response.
+ public static ThumbnailResponse ToResponse(this Thumbnail domainEntity)
+ {
+ return new ThumbnailResponse(
+ domainEntity.Type,
+ domainEntity.Bytes
+ );
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMapping.cs
new file mode 100644
index 00000000..f5c971b3
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMapping.cs
@@ -0,0 +1,28 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.MediaLibrary.Management.Commands.AddLibrary;
+using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
+using Lumina.Contracts.Requests.MediaLibrary.Management;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.MediaLibrary.Management;
+
+///
+/// Extension methods for converting .
+///
+public static class AddMediaLibraryRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted command.
+ public static AddLibraryCommand ToCommand(this AddLibraryRequest request)
+ {
+ return new AddLibraryCommand(
+ request.UserId,
+ request.Title,
+ request.LibraryType,
+ request.ContentLocations
+ );
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryEntityMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryEntityMapping.cs
new file mode 100644
index 00000000..36e0d70d
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryEntityMapping.cs
@@ -0,0 +1,31 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
+using Lumina.Contracts.Responses.MediaLibrary.Management;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.MediaLibrary.Management;
+
+///
+/// Extension methods for converting .
+///
+public static class LibraryEntityMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The repository entity to be converted.
+ /// The converted response entity.
+ public static LibraryResponse ToResponse(this LibraryEntity repositoryEntity)
+ {
+ return new LibraryResponse(
+ repositoryEntity.Id,
+ repositoryEntity.UserId,
+ repositoryEntity.Title,
+ repositoryEntity.LibraryType,
+ repositoryEntity.ContentLocations.Select(location => location.Path).ToList(),
+ repositoryEntity.Created,
+ repositoryEntity.Updated
+ );
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryMapping.cs
new file mode 100644
index 00000000..4cd847a7
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryMapping.cs
@@ -0,0 +1,32 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.MediaLibrary.Management;
+
+///
+/// Extension methods for converting .
+///
+public static class LibraryMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The domain entity to be converted.
+ /// The converted repository entity.
+ public static LibraryEntity ToRepositoryEntity(this Library domainEntity)
+ {
+ return new LibraryEntity
+ {
+ Id = domainEntity.Id.Value,
+ Title = domainEntity.Title,
+ LibraryType = domainEntity.LibraryType,
+ UserId = domainEntity.UserId.Value,
+ ContentLocations = domainEntity.ContentLocations.Select(path => new LibraryContentLocationEntity() { Path = path.Path }).ToList(),
+ Created = domainEntity.Created,
+ Updated = domainEntity.Updated.HasValue ? domainEntity.Updated : null
+ };
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequestMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequestMapping.cs
new file mode 100644
index 00000000..f0f436d8
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequestMapping.cs
@@ -0,0 +1,41 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
+using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
+
+#endregion
+
+namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
+
+///
+/// Extension methods for converting .
+///
+public static class AddBookRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted command.
+ public static AddBookCommand ToCommand(this AddBookRequest request)
+ {
+ return new AddBookCommand(
+ request.Metadata,
+ request.Format,
+ request.Edition,
+ request.VolumeNumber,
+ request.Series,
+ request.ASIN,
+ request.GoodreadsId,
+ request.LCCN,
+ request.OCLCNumber,
+ request.OpenLibraryId,
+ request.LibraryThingId,
+ request.GoogleBooksId,
+ request.BarnesAndNobleId,
+ request.AppleBooksId,
+ request.ISBNs,
+ request.Contributors,
+ request.Ratings
+ );
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookEntityMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookEntityMapping.cs
new file mode 100644
index 00000000..5d543790
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookEntityMapping.cs
@@ -0,0 +1,224 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
+using Lumina.Application.Common.Mapping.Common.Metadata;
+using Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
+using Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Common;
+using Lumina.Contracts.DTO.Common;
+using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary;
+using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
+using Lumina.Domain.Common.Enums.BookLibrary;
+using Lumina.Domain.Common.Primitives;
+using Lumina.Domain.Common.ValueObjects.Metadata;
+using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate;
+using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Entities;
+using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
+
+///
+/// Extension methods for converting .
+///
+public static class BookEntityMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The repository entity to be converted.
+ ///
+ /// An containing either a successfully converted , or an error message.
+ ///
+ public static ErrorOr ToDomainEntity(this BookEntity repositoryEntity)
+ {
+ IEnumerable> tagsResult = repositoryEntity.Tags.ToDomainEntities();
+ foreach (ErrorOr tagResult in tagsResult)
+ if (tagResult.IsError)
+ return tagResult.Errors;
+
+ IEnumerable> genresResult = repositoryEntity.Genres.ToDomainEntities();
+ foreach (ErrorOr genreResult in genresResult)
+ if (genreResult.IsError)
+ return genreResult.Errors;
+
+ IEnumerable> isbnsResult = repositoryEntity.ISBNs.ToDomainEntities();
+ foreach (ErrorOr isbnResult in isbnsResult)
+ if (isbnResult.IsError)
+ return isbnResult.Errors;
+
+ IEnumerable> bookRatingsResult = repositoryEntity.Ratings.ToDomainEntities();
+ foreach (ErrorOr bookRatingResult in bookRatingsResult)
+ if (bookRatingResult.IsError)
+ return bookRatingResult.Errors;
+
+ ErrorOr releaseInfoResult = ReleaseInfo.Create(
+ Optional.FromNullable(repositoryEntity.OriginalReleaseDate),
+ Optional.FromNullable(repositoryEntity.OriginalReleaseYear),
+ Optional.FromNullable(repositoryEntity.ReReleaseDate),
+ Optional.FromNullable(repositoryEntity.ReReleaseYear),
+ Optional.FromNullable(repositoryEntity.ReleaseCountry),
+ Optional.FromNullable(repositoryEntity.ReleaseVersion)
+ );
+ if (releaseInfoResult.IsError)
+ return releaseInfoResult.Errors;
+
+ Optional languageInfo = Optional.None();
+ if (repositoryEntity.LanguageCode is not null)
+ {
+ ErrorOr languageInfoResult = LanguageInfo.Create(
+ repositoryEntity.LanguageCode,
+ repositoryEntity.LanguageName,
+ Optional.FromNullable(repositoryEntity.LanguageNativeName)
+ );
+ if (languageInfoResult.IsError)
+ return languageInfoResult.Errors;
+ languageInfo = languageInfoResult.Value;
+ }
+
+ Optional originalLanguageCode = Optional.None();
+ if (repositoryEntity.OriginalLanguageCode is not null)
+ {
+ ErrorOr originalLanguageInfoResult = LanguageInfo.Create(
+ repositoryEntity.OriginalLanguageCode,
+ repositoryEntity.OriginalLanguageName!,
+ Optional.FromNullable(repositoryEntity.OriginalLanguageNativeName)
+ );
+ if (originalLanguageInfoResult.IsError)
+ return originalLanguageInfoResult.Errors;
+ originalLanguageCode = originalLanguageInfoResult.Value;
+ }
+
+ ErrorOr writtenContentMetadataResult = WrittenContentMetadata.Create(
+ repositoryEntity.Title,
+ Optional.FromNullable(repositoryEntity.OriginalTitle),
+ Optional.FromNullable(repositoryEntity.Description),
+ releaseInfoResult.Value,
+ genresResult.Select(genre => genre.Value).ToList(),
+ tagsResult.Select(tag => tag.Value).ToList(),
+ languageInfo,
+ originalLanguageCode,
+ Optional.FromNullable(repositoryEntity.Publisher),
+ Optional.FromNullable(repositoryEntity.PageCount)
+ );
+ if (writtenContentMetadataResult.IsError)
+ return writtenContentMetadataResult.Errors;
+
+ Optional bookFormat = Optional.FromNullable(repositoryEntity.Format);
+
+ return Book.Create(
+ BookId.Create(repositoryEntity.Id),
+ writtenContentMetadataResult.Value,
+ bookFormat,
+ Optional.FromNullable(repositoryEntity.Edition),
+ Optional.FromNullable(repositoryEntity.VolumeNumber),
+ Optional.None(),
+ Optional.FromNullable(repositoryEntity.ASIN),
+ Optional.FromNullable(repositoryEntity.GoodreadsId),
+ Optional.FromNullable(repositoryEntity.LCCN),
+ Optional.FromNullable(repositoryEntity.OCLCNumber),
+ Optional.FromNullable(repositoryEntity.OpenLibraryId),
+ Optional.FromNullable(repositoryEntity.LibraryThingId),
+ Optional.FromNullable(repositoryEntity.GoogleBooksId),
+ Optional.FromNullable(repositoryEntity.BarnesAndNobleId),
+ Optional.FromNullable(repositoryEntity.AppleBooksId),
+ repositoryEntity.Created,
+ Optional.FromNullable(repositoryEntity.Updated),
+ isbnsResult.Select(isbn => isbn.Value).ToList(),
+ [],
+ bookRatingsResult.Select(bookRating => bookRating.Value).ToList());
+ }
+
+ ///
+ /// Converts to a collection of .
+ ///
+ /// The repository entities to be converted.
+ /// The converted domain entities.
+ ///
+ /// An colection of containing either successfully converted , or error messages.
+ ///
+ public static IEnumerable> ToDomainEntities(this IEnumerable repositoryEntities)
+ {
+ return repositoryEntities.Select(repositoryEntity => repositoryEntity.ToDomainEntity());
+ }
+
+ ///
+ /// Converts to .
+ ///
+ /// The repository entity to be converted.
+ /// The converted response entity.
+ public static BookResponse ToResponse(this BookEntity repositoryEntity)
+ {
+ ReleaseInfoDto releaseInfoEntity = new(
+ repositoryEntity.OriginalReleaseDate,
+ repositoryEntity.OriginalReleaseYear,
+ repositoryEntity.ReReleaseDate,
+ repositoryEntity.ReReleaseYear,
+ repositoryEntity.ReleaseCountry,
+ repositoryEntity.ReleaseVersion
+ );
+ // language and original language make sense only if their subproperties have values
+ LanguageInfoDto? languageInfoEntity = !string.IsNullOrWhiteSpace(repositoryEntity.LanguageCode) ||
+ !string.IsNullOrWhiteSpace(repositoryEntity.LanguageName) ||
+ !string.IsNullOrWhiteSpace(repositoryEntity.LanguageNativeName)
+ ? new LanguageInfoDto(
+ repositoryEntity.LanguageCode,
+ repositoryEntity.LanguageName,
+ repositoryEntity.LanguageNativeName
+ ) : null;
+ LanguageInfoDto? originalLanguageInfoEntity = !string.IsNullOrWhiteSpace(repositoryEntity.OriginalLanguageCode) ||
+ !string.IsNullOrWhiteSpace(repositoryEntity.OriginalLanguageName) ||
+ !string.IsNullOrWhiteSpace(repositoryEntity.OriginalLanguageNativeName)
+ ? new LanguageInfoDto(
+ repositoryEntity.OriginalLanguageCode,
+ repositoryEntity.OriginalLanguageName,
+ repositoryEntity.OriginalLanguageNativeName
+ ) : null;
+ WrittenContentMetadataDto metadata = new(
+ repositoryEntity.Title,
+ repositoryEntity.OriginalTitle,
+ repositoryEntity.Description,
+ releaseInfoEntity,
+ [.. repositoryEntity.Genres.ToResponses()],
+ [.. repositoryEntity.Tags.ToResponses()],
+ languageInfoEntity,
+ originalLanguageInfoEntity,
+ repositoryEntity.Publisher,
+ repositoryEntity.PageCount
+ );
+ return new BookResponse(
+ repositoryEntity.Id,
+ metadata,
+ repositoryEntity.Format,
+ repositoryEntity.Edition,
+ repositoryEntity.VolumeNumber,
+ null,
+ repositoryEntity.ASIN,
+ repositoryEntity.GoodreadsId,
+ repositoryEntity.LCCN,
+ repositoryEntity.OCLCNumber,
+ repositoryEntity.OpenLibraryId,
+ repositoryEntity.LibraryThingId,
+ repositoryEntity.GoogleBooksId,
+ repositoryEntity.BarnesAndNobleId,
+ repositoryEntity.AppleBooksId,
+ [.. repositoryEntity.ISBNs.ToResponses()],
+ null,
+ [.. repositoryEntity.Ratings.ToResponses()],
+ repositoryEntity.Created,
+ repositoryEntity.Updated
+ );
+ }
+
+ ///
+ /// Converts to a collection of .
+ ///
+ /// The repository entities to be converted.
+ /// The converted reponses.
+ public static IEnumerable ToResponses(this IEnumerable repositoryEntities)
+ {
+ return repositoryEntities.Select(repositoryEntity => repositoryEntity.ToResponse());
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookMapping.cs
new file mode 100644
index 00000000..52f4e4a5
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookMapping.cs
@@ -0,0 +1,63 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
+using Lumina.Application.Common.Mapping.Common.Metadata;
+using Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Common;
+using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
+
+///
+/// Extension methods for converting .
+///
+public static class BookMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The domain entity to be converted.
+ /// The converted repository entity.
+ public static BookEntity ToRepositoryEntity(this Book domainEntity)
+ {
+ return new BookEntity
+ {
+ Id = domainEntity.Id.Value,
+ Title = domainEntity.Metadata.Title,
+ OriginalTitle = domainEntity.Metadata.OriginalTitle.HasValue ? domainEntity.Metadata.OriginalTitle.Value : null,
+ Description = domainEntity.Metadata.Description.HasValue ? domainEntity.Metadata.Description.Value : null,
+ OriginalReleaseDate = domainEntity.Metadata.ReleaseInfo.OriginalReleaseDate.HasValue ? domainEntity.Metadata.ReleaseInfo.OriginalReleaseDate.Value : null,
+ OriginalReleaseYear = domainEntity.Metadata.ReleaseInfo.OriginalReleaseYear.HasValue ? domainEntity.Metadata.ReleaseInfo.OriginalReleaseYear.Value : null,
+ ReReleaseDate = domainEntity.Metadata.ReleaseInfo.ReReleaseDate.HasValue ? domainEntity.Metadata.ReleaseInfo.ReReleaseDate.Value : null,
+ ReReleaseYear = domainEntity.Metadata.ReleaseInfo.ReReleaseYear.HasValue ? domainEntity.Metadata.ReleaseInfo.ReReleaseYear.Value : null,
+ ReleaseCountry = domainEntity.Metadata.ReleaseInfo.ReleaseCountry.HasValue ? domainEntity.Metadata.ReleaseInfo.ReleaseCountry.Value : null,
+ ReleaseVersion = domainEntity.Metadata.ReleaseInfo.ReleaseVersion.HasValue ? domainEntity.Metadata.ReleaseInfo.ReleaseVersion.Value : null,
+ LanguageCode = domainEntity.Metadata.Language.HasValue ? domainEntity.Metadata.Language.Value.LanguageCode : null,
+ LanguageName = domainEntity.Metadata.Language.HasValue ? domainEntity.Metadata.Language.Value.LanguageName : null,
+ LanguageNativeName = domainEntity.Metadata.Language.HasValue ? domainEntity.Metadata.Language.Value.NativeName.Value : null,
+ OriginalLanguageCode = domainEntity.Metadata.OriginalLanguage.HasValue ? domainEntity.Metadata.OriginalLanguage.Value.LanguageCode : null,
+ OriginalLanguageName = domainEntity.Metadata.OriginalLanguage.HasValue ? domainEntity.Metadata.OriginalLanguage.Value.LanguageName : null,
+ OriginalLanguageNativeName = domainEntity.Metadata.OriginalLanguage.HasValue ? domainEntity.Metadata.OriginalLanguage.Value.NativeName.Value : null,
+ Tags = domainEntity.Metadata.Tags.ToRepositoryEntities().ToHashSet(),
+ Genres = domainEntity.Metadata.Genres.ToRepositoryEntities().ToHashSet(),
+ Publisher = domainEntity.Metadata.Publisher.HasValue ? domainEntity.Metadata.Publisher.Value : null,
+ PageCount = domainEntity.Metadata.PageCount.HasValue ? domainEntity.Metadata.PageCount.Value : null,
+ Format = domainEntity.Format.HasValue ? domainEntity.Format.Value : null,
+ Edition = domainEntity.Edition.HasValue ? domainEntity.Edition.Value : null,
+ VolumeNumber = domainEntity.VolumeNumber.HasValue ? domainEntity.VolumeNumber.Value : null,
+ ASIN = domainEntity.ASIN.HasValue ? domainEntity.ASIN.Value : null,
+ GoodreadsId = domainEntity.GoodreadsId.HasValue ? domainEntity.GoodreadsId.Value : null,
+ LCCN = domainEntity.LCCN.HasValue ? domainEntity.LCCN.Value : null,
+ OCLCNumber = domainEntity.OCLCNumber.HasValue ? domainEntity.OCLCNumber.Value : null,
+ OpenLibraryId = domainEntity.OpenLibraryId.HasValue ? domainEntity.OpenLibraryId.Value : null,
+ LibraryThingId = domainEntity.LibraryThingId.HasValue ? domainEntity.LibraryThingId.Value : null,
+ GoogleBooksId = domainEntity.GoogleBooksId.HasValue ? domainEntity.GoogleBooksId.Value : null,
+ BarnesAndNobleId = domainEntity.BarnesAndNobleId.HasValue ? domainEntity.BarnesAndNobleId.Value : null,
+ AppleBooksId = domainEntity.AppleBooksId.HasValue ? domainEntity.AppleBooksId.Value : null,
+ ISBNs = domainEntity.ISBNs.ToRepositoryEntities().ToList(),
+ Ratings = domainEntity.Ratings.ToRepositoryEntities().ToList(),
+ Created = domainEntity.Created,
+ Updated = domainEntity.Updated.HasValue ? domainEntity.Updated : null
+ };
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/BookRatingDtoMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/BookRatingDtoMapping.cs
new file mode 100644
index 00000000..16616979
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/BookRatingDtoMapping.cs
@@ -0,0 +1,42 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
+using Lumina.Domain.Common.Enums.BookLibrary;
+using Lumina.Domain.Common.Primitives;
+using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
+using System.Collections.Generic;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Common;
+
+///
+/// Extension methods for converting .
+///
+public static class BookRatingDtoMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The DTO to be converted.
+ /// The converted domain entity.
+ public static ErrorOr ToDomainEntity(this BookRatingDto dto)
+ {
+ return BookRating.Create(
+ dto.Value ?? default,
+ dto.MaxValue ?? default,
+ Optional.FromNullable(dto.Source),
+ Optional.FromNullable(dto.VoteCount)
+ );
+ }
+
+ ///
+ /// Converts to a collection of .
+ ///
+ /// The DTOs to be converted.
+ /// The converted domain entities.
+ public static IEnumerable> ToDomainEntities(this IEnumerable dtos)
+ {
+ return dtos.Select(domainEntity => domainEntity.ToDomainEntity());
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/BookRatingEntityMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/BookRatingEntityMapping.cs
new file mode 100644
index 00000000..da176890
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/BookRatingEntityMapping.cs
@@ -0,0 +1,68 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
+using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
+using Lumina.Domain.Common.Enums.BookLibrary;
+using Lumina.Domain.Common.Primitives;
+using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
+using System.Collections.Generic;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Common;
+
+///
+/// Extension methods for converting .
+///
+public static class BookRatingEntityMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The repository entity to be converted.
+ /// The converted DTO.
+ public static BookRatingDto ToResponse(this BookRatingEntity repositoryEntity)
+ {
+ return new BookRatingDto(
+ repositoryEntity.Value ?? default,
+ repositoryEntity.MaxValue ?? default,
+ repositoryEntity.Source,
+ repositoryEntity.VoteCount
+ );
+ }
+
+ ///
+ /// Converts to a collection of .
+ ///
+ /// The repository entities to be converted.
+ /// The converted DTOs.
+ public static IEnumerable ToResponses(this IEnumerable repositoryEntities)
+ {
+ return repositoryEntities.Select(responseEntity => responseEntity.ToResponse());
+ }
+
+ ///
+ /// Converts to .
+ ///
+ /// The repository entity to be converted.
+ /// The converted domain entity.
+ public static ErrorOr ToDomainEntity(this BookRatingEntity repositoryEntity)
+ {
+ return BookRating.Create(
+ repositoryEntity.Value ?? default,
+ repositoryEntity.MaxValue ?? default,
+ Optional.FromNullable(repositoryEntity.Source),
+ Optional.FromNullable(repositoryEntity.VoteCount)
+ );
+ }
+
+ ///
+ /// Converts to a collection of .
+ ///
+ /// The repository entities to be converted.
+ /// The converted domain entities.
+ public static IEnumerable> ToDomainEntities(this IEnumerable repositoryEntities)
+ {
+ return repositoryEntities.Select(domainEntity => domainEntity.ToDomainEntity());
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/BookRatingMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/BookRatingMapping.cs
new file mode 100644
index 00000000..ec2c7f5b
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/BookRatingMapping.cs
@@ -0,0 +1,39 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
+using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
+using System.Collections.Generic;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Common;
+
+///
+/// Extension methods for converting .
+///
+public static class BookRatingMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The domain entity to be converted.
+ /// The converted repository entity.
+ public static BookRatingEntity ToRepositoryEntity(this BookRating domainEntity)
+ {
+ return new BookRatingEntity(
+ domainEntity.Value,
+ domainEntity.MaxValue,
+ domainEntity.Source.HasValue ? domainEntity.Source.Value : null,
+ domainEntity.VoteCount.HasValue ? domainEntity.VoteCount.Value : null
+ );
+ }
+
+ ///
+ /// Converts to a collection of .
+ ///
+ /// The domain entities to be converted.
+ /// The converted repository entities.
+ public static IEnumerable ToRepositoryEntities(this IEnumerable domainEntities)
+ {
+ return domainEntities.Select(domainEntity => domainEntity.ToRepositoryEntity());
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/IsbnDtoMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/IsbnDtoMapping.cs
new file mode 100644
index 00000000..407edcb1
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/IsbnDtoMapping.cs
@@ -0,0 +1,41 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
+using Lumina.Domain.Common.Enums.BookLibrary;
+using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
+using System.Collections.Generic;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Common;
+
+///
+/// Extension methods for converting .
+///
+public static class IsbnDtoMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The DTO to be converted.
+ ///
+ /// An containing either a successfully converted , or an error message.
+ ///
+ public static ErrorOr ToDomainEntity(this IsbnDto dto)
+ {
+ return Isbn.Create(
+ dto.Value,
+ dto.Format ?? IsbnFormat.Isbn13
+ );
+ }
+
+ ///
+ /// Converts to a collection of .
+ ///
+ /// The DTOs to be converted.
+ /// The converted domain entities.
+ public static IEnumerable> ToDomainEntities(this IEnumerable dtos)
+ {
+ return dtos.Select(domainEntity => domainEntity.ToDomainEntity());
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/IsbnEntityMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/IsbnEntityMapping.cs
new file mode 100644
index 00000000..f889d41a
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/IsbnEntityMapping.cs
@@ -0,0 +1,62 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
+using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
+using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
+using System.Collections.Generic;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Common;
+
+///
+/// Extension methods for converting .
+///
+public static class IsbnEntityMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The repository entity to be converted.
+ /// The converted DTO.
+ public static IsbnDto ToResponse(this IsbnEntity repositoryEntity)
+ {
+ return new IsbnDto(
+ repositoryEntity.Value ?? default,
+ repositoryEntity.Format ?? null
+ );
+ }
+
+ ///
+ /// Converts to a collection of .
+ ///
+ /// The repository entities to be converted.
+ /// The converted DTOs.
+ public static IEnumerable ToResponses(this IEnumerable repositoryEntities)
+ {
+ return repositoryEntities.Select(responseEntity => responseEntity.ToResponse());
+ }
+
+ ///
+ /// Converts to .
+ ///
+ /// The repository entity to be converted.
+ /// The converted domain entity.
+ public static ErrorOr ToDomainEntity(this IsbnEntity repositoryEntity)
+ {
+ return Isbn.Create(
+ repositoryEntity.Value ?? default,
+ repositoryEntity.Format ?? default
+ );
+ }
+
+ ///
+ /// Converts to a collection of .
+ ///
+ /// The repository entities to be converted.
+ /// The converted domain entities.
+ public static IEnumerable> ToDomainEntities(this IEnumerable repositoryEntities)
+ {
+ return repositoryEntities.Select(domainEntity => domainEntity.ToDomainEntity());
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/IsbnMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/IsbnMapping.cs
new file mode 100644
index 00000000..a49b9728
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/IsbnMapping.cs
@@ -0,0 +1,37 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
+using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
+using System.Collections.Generic;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Common;
+
+///
+/// Extension methods for converting .
+///
+public static class IsbnMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The domain entity to be converted.
+ /// The converted repository entity.
+ public static IsbnEntity ToRepositoryEntity(this Isbn domainEntity)
+ {
+ return new IsbnEntity(
+ domainEntity.Value,
+ domainEntity.Format
+ );
+ }
+
+ ///
+ /// Converts to a collection of .
+ ///
+ /// The domain entities to be converted.
+ /// The converted repository entities.
+ public static IEnumerable ToRepositoryEntities(this IEnumerable domainEntities)
+ {
+ return domainEntities.Select(domainEntity => domainEntity.ToRepositoryEntity());
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserEntityMapping.cs b/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserEntityMapping.cs
new file mode 100644
index 00000000..1eccd2c6
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserEntityMapping.cs
@@ -0,0 +1,27 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Contracts.Responses.UsersManagement.Users;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.UsersManagement.Users;
+
+///
+/// Extension methods for converting .
+///
+public static class UserEntityMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The repository entity to be converted.
+ /// The converted response entity.
+ public static UserResponse ToResponse(this UserEntity repositoryEntity)
+ {
+ return new UserResponse(
+ repositoryEntity.Id,
+ repositoryEntity.Username,
+ repositoryEntity.Created,
+ repositoryEntity.Updated
+ );
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserMapping.cs b/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserMapping.cs
new file mode 100644
index 00000000..9b8a6ad3
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserMapping.cs
@@ -0,0 +1,29 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.UsersManagement.Users;
+
+///
+/// Extension methods for converting .
+///
+public static class UserMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The domain entity to be converted.
+ /// The repository entity containing sensitive information not mapped to the Domain entity.
+ ///
+ /// Because Authentication and Authorization are Application Layer concerns, the members involved in those concerns are not mirrored in the Domain entity.
+ /// However, since Entity Framework updates an entire entity, when mapping from the Domain entity to the DAL entity, one still needs to provide the
+ /// values of the non-included members, such that they are not overriden with . Those values should come in the requested .
+ ///
+ /// The converted repository entity.
+ public static UserEntity ToRepositoryEntity(this User domainEntity, UserEntity repositoryEntity)
+ {
+ repositoryEntity.Username = domainEntity.Username;
+ return repositoryEntity;
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/WrittenContentLibrary/BookLibrary/BookMappingConfig.cs b/src/Lumina.Application/Common/Mapping/WrittenContentLibrary/BookLibrary/BookMappingConfig.cs
deleted file mode 100644
index 03dd13d7..00000000
--- a/src/Lumina.Application/Common/Mapping/WrittenContentLibrary/BookLibrary/BookMappingConfig.cs
+++ /dev/null
@@ -1,132 +0,0 @@
-#region ========================================================================= USING =====================================================================================
-using Lumina.Contracts.Enums.BookLibrary;
-using Lumina.Contracts.Models.WrittenContentLibrary.BookLibrary;
-using Lumina.Domain.Common.Primitives;
-using Lumina.Domain.Common.ValueObjects.Metadata;
-using Lumina.Domain.Core.Aggregates.MediaContributor.MediaContributorAggregate.ValueObjects;
-using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate;
-using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.Entities;
-using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects;
-using Mapster;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-#endregion
-
-namespace Lumina.Application.Common.Mapping.WrittenContentLibrary.BookLibrary;
-
-///
-/// Mapping configuration for books between the domain object and the persistence object.
-///
-public class BookMappingConfig : IRegister
-{
- ///
- /// Registers the mapping configuration.
- ///
- /// The type adapter configuration.
- public void Register(TypeAdapterConfig config)
- {
- config.NewConfig()
- .Map(dest => dest.Id, src => src.Id.Value)
- .Map(dest => dest.Title, src => src.Metadata.Title)
- .Map(dest => dest.OriginalTitle, src => src.Metadata.OriginalTitle.HasValue ? src.Metadata.OriginalTitle.Value : default)
- .Map(dest => dest.Description, src => src.Metadata.Description.HasValue ? src.Metadata.Description.Value : default)
- .Map(dest => dest.OriginalReleaseDate, src => src.Metadata.ReleaseInfo.OriginalReleaseDate.HasValue ? src.Metadata.ReleaseInfo.OriginalReleaseDate.Value : default)
- .Map(dest => dest.OriginalReleaseYear, src => src.Metadata.ReleaseInfo.OriginalReleaseYear.HasValue ? src.Metadata.ReleaseInfo.OriginalReleaseYear.Value : default)
- .Map(dest => dest.ReReleaseDate, src => src.Metadata.ReleaseInfo.ReReleaseDate.HasValue ? src.Metadata.ReleaseInfo.ReReleaseDate.Value : default)
- .Map(dest => dest.ReReleaseYear, src => src.Metadata.ReleaseInfo.ReReleaseYear.HasValue ? src.Metadata.ReleaseInfo.ReReleaseYear.Value : default)
- .Map(dest => dest.ReleaseCountry, src => src.Metadata.ReleaseInfo.ReleaseCountry.HasValue ? src.Metadata.ReleaseInfo.ReleaseCountry.Value : default)
- .Map(dest => dest.ReleaseVersion, src => src.Metadata.ReleaseInfo.ReleaseVersion.HasValue ? src.Metadata.ReleaseInfo.ReleaseVersion.Value : default)
- .Map(dest => dest.LanguageCode, src => src.Metadata.Language.HasValue ? src.Metadata.Language.Value.LanguageCode : default)
- .Map(dest => dest.LanguageName, src => src.Metadata.Language.HasValue ? src.Metadata.Language.Value.LanguageName : default)
- .Map(dest => dest.LanguageNativeName, src => src.Metadata.Language.HasValue ? src.Metadata.Language.Value.NativeName : default)
- .Map(dest => dest.OriginalLanguageCode, src => src.Metadata.OriginalLanguage.HasValue ? src.Metadata.OriginalLanguage.Value.LanguageCode : default)
- .Map(dest => dest.OriginalLanguageName, src => src.Metadata.OriginalLanguage.HasValue ? src.Metadata.OriginalLanguage.Value.LanguageName : default)
- .Map(dest => dest.OriginalLanguageNativeName, src => src.Metadata.OriginalLanguage.HasValue ? src.Metadata.OriginalLanguage.Value.NativeName : default)
- .Map(dest => dest.Tags, src => src.Metadata.Tags)
- .Map(dest => dest.Genres, src => src.Metadata.Genres)
- .Map(dest => dest.Publisher, src => src.Metadata.Publisher.HasValue ? src.Metadata.Publisher.Value : default)
- .Map(dest => dest.PageCount, src => src.Metadata.PageCount.HasValue ? src.Metadata.PageCount.Value : default)
- .Map(dest => dest.Format, src => src.Format.ToString())
- .Map(dest => dest.Edition, src => src.Edition.HasValue ? src.Edition.Value : default)
- .Map(dest => dest.VolumeNumber, src => src.VolumeNumber.HasValue ? src.VolumeNumber.Value : default)
- .Map(dest => dest.ASIN, src => src.ASIN.HasValue ? src.ASIN.Value : default)
- .Map(dest => dest.GoodreadsId, src => src.GoodreadsId.HasValue ? src.GoodreadsId.Value : default)
- .Map(dest => dest.LCCN, src => src.LCCN.HasValue ? src.LCCN.Value : default)
- .Map(dest => dest.OCLCNumber, src => src.OCLCNumber.HasValue ? src.OCLCNumber.Value : default)
- .Map(dest => dest.OpenLibraryId, src => src.OpenLibraryId.HasValue ? src.OpenLibraryId.Value : default)
- .Map(dest => dest.LibraryThingId, src => src.LibraryThingId.HasValue ? src.LibraryThingId.Value : default)
- .Map(dest => dest.GoogleBooksId, src => src.GoogleBooksId.HasValue ? src.GoogleBooksId.Value : default)
- .Map(dest => dest.BarnesAndNobleId, src => src.BarnesAndNobleId.HasValue ? src.BarnesAndNobleId.Value : default)
- .Map(dest => dest.AppleBooksId, src => src.AppleBooksId.HasValue ? src.AppleBooksId.Value : default)
- .Map(dest => dest.ISBNs, src => src.ISBNs)
- .Map(dest => dest.Ratings, src => src.Ratings)
- .Map(dest => dest.Created, src => src.Created)
- .Map(dest => dest.Updated, src => src.Updated.HasValue ? src.Updated : null);
-
- config.NewConfig()
- .Map(dest => dest.Value, src => src.Value)
- .Map(dest => dest.MaxValue, src => src.MaxValue)
- .Map(dest => dest.VoteCount, src => src.VoteCount.HasValue ? src.VoteCount.Value : default)
- .Map(dest => dest.Source, src => src.Source.HasValue ? src.Source.Value : default);
-
- config.NewConfig, BookRatingSource?>()
- .MapWith(src => src.HasValue ? src.Value : default);
-
- // from BookModel to Book
- config.NewConfig()
- .MapWith(src => Book.Create(
- BookId.Create(src.Id),
- WrittenContentMetadata.Create(
- src.Title,
- Optional.FromNullable(src.OriginalTitle),
- Optional.FromNullable(src.Description),
- ReleaseInfo.Create(
- Optional.FromNullable(src.OriginalReleaseDate),
- Optional.FromNullable(src.OriginalReleaseYear),
- Optional.FromNullable(src.ReReleaseDate),
- Optional.FromNullable(src.ReReleaseYear),
- Optional.FromNullable(src.ReleaseCountry),
- Optional.FromNullable(src.ReleaseVersion)
- ).Value,
- src.Genres.Select(g => Genre.Create(g.Name!).Value).ToList(),
- src.Tags.Select(t => Tag.Create(t.Name!).Value).ToList(),
- src.LanguageCode != null ? LanguageInfo.Create(
- src.LanguageCode,
- src.LanguageName!,
- Optional.FromNullable(src.LanguageNativeName)
- ).Value : Optional.None(),
- src.OriginalLanguageCode != null ? LanguageInfo.Create(
- src.OriginalLanguageCode,
- src.OriginalLanguageName!,
- Optional.FromNullable(src.OriginalLanguageNativeName)
- ).Value : Optional.None(),
- Optional.FromNullable(src.Publisher),
- Optional.FromNullable(src.PageCount)
- ).Value,
- Optional.FromNullable(!string.IsNullOrWhiteSpace(src.Format) ? Enum.Parse(src.Format) : default),
- Optional.FromNullable(src.Edition),
- Optional.FromNullable(src.VolumeNumber),
- Optional.None(),
- Optional.FromNullable(src.ASIN),
- Optional.FromNullable(src.GoodreadsId),
- Optional.FromNullable(src.LCCN),
- Optional.FromNullable(src.OCLCNumber),
- Optional.FromNullable(src.OpenLibraryId),
- Optional.FromNullable(src.LibraryThingId),
- Optional.FromNullable(src.GoogleBooksId),
- Optional.FromNullable(src.BarnesAndNobleId),
- Optional.FromNullable(src.AppleBooksId),
- src.Created,
- Optional.FromNullable(src.Updated),
- src.ISBNs.Select(i => Isbn.Create(i.Value!, i.Format ?? default).Value).ToList(),
- new List(),
- src.Ratings.Select(r => BookRating.Create(
- r.Value ?? default,
- r.MaxValue ?? default,
- Optional.FromNullable(r.Source),
- Optional.FromNullable(r.VoteCount)
- ).Value).ToList()
- ).Value);
- }
-}
\ No newline at end of file
diff --git a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectories/GetDirectoriesQuery.cs b/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectories/GetDirectoriesQuery.cs
deleted file mode 100644
index b303fec9..00000000
--- a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectories/GetDirectoriesQuery.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-#region ========================================================================= USING =====================================================================================
-using ErrorOr;
-using Lumina.Contracts.Responses.FileManagement;
-using Mediator;
-using System.Collections.Generic;
-#endregion
-
-namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetDirectories;
-
-///
-/// Query for retrieving the list of directories at a path.
-///
-/// The path for which to retrieve the list of directories.
-/// Whether to include hidden directories or not.
-public record GetDirectoriesQuery(string Path, bool IncludeHiddenElements) : IRequest>>;
\ No newline at end of file
diff --git a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetTreeDirectories/GetTreeDirectoriesQuery.cs b/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetTreeDirectories/GetTreeDirectoriesQuery.cs
deleted file mode 100644
index 5e447708..00000000
--- a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetTreeDirectories/GetTreeDirectoriesQuery.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-#region ========================================================================= USING =====================================================================================
-using ErrorOr;
-using Lumina.Contracts.Responses.FileManagement;
-using Mediator;
-using System.Collections.Generic;
-#endregion
-
-namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetTreeDirectories;
-
-///
-/// Query for retrieving the list of directories at a path.
-///
-/// The path for which to retrieve the list of directories.
-/// Whether to include hidden directories or not.
-public record GetTreeDirectoriesQuery(string Path, bool IncludeHiddenElements) : IRequest>>;
\ No newline at end of file
diff --git a/src/Lumina.Application/Core/FileManagement/Files/Queries/GetFiles/GetFilesQuery.cs b/src/Lumina.Application/Core/FileManagement/Files/Queries/GetFiles/GetFilesQuery.cs
deleted file mode 100644
index 8393d753..00000000
--- a/src/Lumina.Application/Core/FileManagement/Files/Queries/GetFiles/GetFilesQuery.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-#region ========================================================================= USING =====================================================================================
-using ErrorOr;
-using Lumina.Contracts.Responses.FileManagement;
-using Mediator;
-using System.Collections.Generic;
-#endregion
-
-namespace Lumina.Application.Core.FileManagement.Files.Queries.GetFiles;
-
-///
-/// Query for retrieving the list of files at a path.
-///
-/// The path for which to retrieve the list of files.
-/// Whether to include hidden files and directories or not.
-public record GetFilesQuery(string Path, bool IncludeHiddenElements) : IRequest>>;
\ No newline at end of file
diff --git a/src/Lumina.Application/Core/FileManagement/Files/Queries/GetTreeFiles/GetTreeFilesQuery.cs b/src/Lumina.Application/Core/FileManagement/Files/Queries/GetTreeFiles/GetTreeFilesQuery.cs
deleted file mode 100644
index 7b9c7bc7..00000000
--- a/src/Lumina.Application/Core/FileManagement/Files/Queries/GetTreeFiles/GetTreeFilesQuery.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-#region ========================================================================= USING =====================================================================================
-using ErrorOr;
-using Lumina.Contracts.Responses.FileManagement;
-using Mediator;
-using System.Collections.Generic;
-#endregion
-
-namespace Lumina.Application.Core.FileManagement.Files.Queries.GetTreeFiles;
-
-///
-/// Query for retrieving the list of files at a path.
-///
-/// The path for which to retrieve the list of files.
-/// Whether to include hidden files and directories or not.
-public record GetTreeFilesQuery(string Path, bool IncludeHiddenElements) : IRequest>>;
\ No newline at end of file
diff --git a/src/Lumina.Application/Core/FileManagement/Paths/Commands/CombinePath/CombinePathCommand.cs b/src/Lumina.Application/Core/FileManagement/Paths/Commands/CombinePath/CombinePathCommand.cs
deleted file mode 100644
index 44e08e79..00000000
--- a/src/Lumina.Application/Core/FileManagement/Paths/Commands/CombinePath/CombinePathCommand.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-#region ========================================================================= USING =====================================================================================
-using ErrorOr;
-using Lumina.Contracts.Responses.FileManagement;
-using Mediator;
-#endregion
-
-namespace Lumina.Application.Core.FileManagement.Paths.Commands.CombinePath;
-
-///
-/// Command for combining two file system path.
-///
-/// The path to combine to.
-/// The path to combine with.
-public record CombinePathCommand(
- string OriginalPath, string NewPath
-) : IRequest>;
\ No newline at end of file
diff --git a/src/Lumina.Application/Core/FileManagement/Paths/Commands/SplitPath/SplitPathCommand.cs b/src/Lumina.Application/Core/FileManagement/Paths/Commands/SplitPath/SplitPathCommand.cs
deleted file mode 100644
index f1b9ad02..00000000
--- a/src/Lumina.Application/Core/FileManagement/Paths/Commands/SplitPath/SplitPathCommand.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-#region ========================================================================= USING =====================================================================================
-using ErrorOr;
-using Lumina.Contracts.Responses.FileManagement;
-using Mediator;
-using System.Collections.Generic;
-#endregion
-
-namespace Lumina.Application.Core.FileManagement.Paths.Commands.SplitPath;
-
-///
-/// Command for splitting a file system path.
-///
-/// The path to split.
-public record SplitPathCommand(
- string Path
-) : IRequest>>;
\ No newline at end of file
diff --git a/src/Lumina.Application/Core/FileManagement/Paths/Queries/CheckPathExists/CheckPathExistsQuery.cs b/src/Lumina.Application/Core/FileManagement/Paths/Queries/CheckPathExists/CheckPathExistsQuery.cs
deleted file mode 100644
index dcba55c1..00000000
--- a/src/Lumina.Application/Core/FileManagement/Paths/Queries/CheckPathExists/CheckPathExistsQuery.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-#region ========================================================================= USING =====================================================================================
-using Lumina.Contracts.Responses.FileManagement;
-using Mediator;
-#endregion
-
-namespace Lumina.Application.Core.FileManagement.Paths.Queries.CheckPathExists;
-
-///
-/// Query for retrieving the existence of a file system path.
-///
-/// The path for which to check the existence.
-/// Whether to include hidden file system elements or not.
-public record CheckPathExistsQuery(string Path, bool IncludeHiddenElements) : IRequest;
diff --git a/src/Lumina.Application/Core/FileManagement/Paths/Queries/GetPathParent/GetPathParentQuery.cs b/src/Lumina.Application/Core/FileManagement/Paths/Queries/GetPathParent/GetPathParentQuery.cs
deleted file mode 100644
index f4d00063..00000000
--- a/src/Lumina.Application/Core/FileManagement/Paths/Queries/GetPathParent/GetPathParentQuery.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-#region ========================================================================= USING =====================================================================================
-using ErrorOr;
-using Lumina.Contracts.Responses.FileManagement;
-using Mediator;
-using System.Collections.Generic;
-#endregion
-
-namespace Lumina.Application.Core.FileManagement.Paths.Queries.GetPathParent;
-
-///
-/// Query for retrieving the parent of a file system path.
-///
-/// The path for which to get the parent.
-public record GetPathParentQuery(string Path) : IRequest>>;
\ No newline at end of file
diff --git a/src/Lumina.Application/Core/FileManagement/Paths/Queries/GetPathRoot/GetPathRootQuery.cs b/src/Lumina.Application/Core/FileManagement/Paths/Queries/GetPathRoot/GetPathRootQuery.cs
deleted file mode 100644
index 89df4002..00000000
--- a/src/Lumina.Application/Core/FileManagement/Paths/Queries/GetPathRoot/GetPathRootQuery.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-#region ========================================================================= USING =====================================================================================
-using ErrorOr;
-using Lumina.Contracts.Responses.FileManagement;
-using Mediator;
-#endregion
-
-namespace Lumina.Application.Core.FileManagement.Paths.Queries.GetPathRoot;
-
-///
-/// Query for retrieving the root of a path.
-///
-/// The path for which to get the path root.
-public record GetPathRootQuery(string Path) : IRequest>;
\ No newline at end of file
diff --git a/src/Lumina.Application/Core/FileManagement/Paths/Queries/ValidatePath/ValidatePathQuery.cs b/src/Lumina.Application/Core/FileManagement/Paths/Queries/ValidatePath/ValidatePathQuery.cs
deleted file mode 100644
index 899c3a6b..00000000
--- a/src/Lumina.Application/Core/FileManagement/Paths/Queries/ValidatePath/ValidatePathQuery.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-#region ========================================================================= USING =====================================================================================
-using Lumina.Contracts.Responses.FileManagement;
-using Mediator;
-#endregion
-
-namespace Lumina.Application.Core.FileManagement.Paths.Queries.ValidatePath;
-
-///
-/// Query for validating a path.
-///
-/// The path to be validated.
-public record ValidatePathQuery(string Path) : IRequest;
\ No newline at end of file
diff --git a/src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetDirectories/GetDirectoriesQuery.cs b/src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetDirectories/GetDirectoriesQuery.cs
new file mode 100644
index 00000000..c4be3e4b
--- /dev/null
+++ b/src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetDirectories/GetDirectoriesQuery.cs
@@ -0,0 +1,20 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Contracts.Responses.FileSystemManagement.Directories;
+using Mediator;
+using System.Collections.Generic;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetDirectories;
+
+///
+/// Query for retrieving the list of directories at a path.
+///
+/// The path for which to retrieve the list of directories.
+/// Whether to include hidden directories or not.
+[DebuggerDisplay("Path: {Path}")]
+public record GetDirectoriesQuery(
+ string? Path,
+ bool IncludeHiddenElements
+) : IRequest>>;
diff --git a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectories/GetDirectoriesQueryHandler.cs b/src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetDirectories/GetDirectoriesQueryHandler.cs
similarity index 71%
rename from src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectories/GetDirectoriesQueryHandler.cs
rename to src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetDirectories/GetDirectoriesQueryHandler.cs
index d182d486..ea47bb58 100644
--- a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectories/GetDirectoriesQueryHandler.cs
+++ b/src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetDirectories/GetDirectoriesQueryHandler.cs
@@ -1,17 +1,16 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
-using Lumina.Contracts.Responses.FileManagement;
-using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
-using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
-using Mapster;
-using MapsterMapper;
+using Lumina.Application.Common.Mapping.FileSystemManagement.Directories;
+using Lumina.Contracts.Responses.FileSystemManagement.Directories;
+using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
+using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
using Mediator;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
#endregion
-namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetDirectories;
+namespace Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetDirectories;
///
/// Handler for the query to get all directories.
@@ -19,17 +18,14 @@ namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetDirector
public class GetDirectoriesQueryHandler : IRequestHandler>>
{
private readonly IDirectoryService _directoryService;
- private readonly IMapper _mapper;
///
/// Initializes a new instance of the class.
///
/// Injected service for handling directories.
- /// Injected service for mapping objects.
- public GetDirectoriesQueryHandler(IDirectoryService directoryService, IMapper mapper)
+ public GetDirectoriesQueryHandler(IDirectoryService directoryService)
{
_directoryService = directoryService;
- _mapper = mapper;
}
///
@@ -42,7 +38,7 @@ public class GetDirectoriesQueryHandler : IRequestHandler
public ValueTask>> Handle(GetDirectoriesQuery request, CancellationToken cancellationToken)
{
- ErrorOr> result = _directoryService.GetSubdirectories(request.Path, request.IncludeHiddenElements);
- return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(_mapper.Map>(values)), errors => errors));
+ ErrorOr> result = _directoryService.GetSubdirectories(request.Path!, request.IncludeHiddenElements);
+ return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(values.ToResponses()), errors => errors));
}
}
diff --git a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectories/GetDirectoriesQueryValidator.cs b/src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetDirectories/GetDirectoriesQueryValidator.cs
similarity index 75%
rename from src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectories/GetDirectoriesQueryValidator.cs
rename to src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetDirectories/GetDirectoriesQueryValidator.cs
index 96fe8a25..95253b8f 100644
--- a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectories/GetDirectoriesQueryValidator.cs
+++ b/src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetDirectories/GetDirectoriesQueryValidator.cs
@@ -3,7 +3,7 @@ using FluentValidation;
using Lumina.Domain.Common.Errors;
#endregion
-namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetDirectories;
+namespace Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetDirectories;
///
/// Validates the needed validation rules for .
@@ -15,6 +15,6 @@ public class GetDirectoriesQueryValidator : AbstractValidator
public GetDirectoriesQueryValidator()
{
- RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileManagement.PathCannotBeEmpty.Code);
+ RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
}
}
\ No newline at end of file
diff --git a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectoryTree/GetDirectoryTreeQuery.cs b/src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetDirectoryTree/GetDirectoryTreeQuery.cs
similarity index 61%
rename from src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectoryTree/GetDirectoryTreeQuery.cs
rename to src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetDirectoryTree/GetDirectoryTreeQuery.cs
index 2142c2d6..2692a771 100644
--- a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectoryTree/GetDirectoryTreeQuery.cs
+++ b/src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetDirectoryTree/GetDirectoryTreeQuery.cs
@@ -1,11 +1,12 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
-using Lumina.Contracts.Responses.FileManagement;
+using Lumina.Contracts.Responses.FileSystemManagement.Common;
using Mediator;
using System.Collections.Generic;
+using System.Diagnostics;
#endregion
-namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetDirectoryTree;
+namespace Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetDirectoryTree;
///
/// Query for retrieving the tree of directories of a path.
@@ -13,4 +14,9 @@ namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetDirector
/// The path for which to retrieve the tree of directories.
/// Whether to include files in the directory tree or not.
/// Whether to include hidden files and directories or not.
-public record GetDirectoryTreeQuery(string Path, bool IncludeFiles, bool IncludeHiddenElements) : IRequest>>;
+[DebuggerDisplay("Path: {Path}")]
+public record GetDirectoryTreeQuery(
+ string? Path,
+ bool IncludeFiles,
+ bool IncludeHiddenElements
+) : IRequest>>;
diff --git a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectoryTree/GetDirectoryTreeQueryHandler.cs b/src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetDirectoryTree/GetDirectoryTreeQueryHandler.cs
similarity index 90%
rename from src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectoryTree/GetDirectoryTreeQueryHandler.cs
rename to src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetDirectoryTree/GetDirectoryTreeQueryHandler.cs
index cda64871..ccc9782d 100644
--- a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectoryTree/GetDirectoryTreeQueryHandler.cs
+++ b/src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetDirectoryTree/GetDirectoryTreeQueryHandler.cs
@@ -1,12 +1,12 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
-using Lumina.Contracts.Enums.FileSystem;
-using Lumina.Contracts.Responses.FileManagement;
-using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate;
-using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
-using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
-using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
-using Mapster;
+using Lumina.Application.Common.Mapping.FileSystemManagement.FileSystem;
+using Lumina.Domain.Common.Enums.FileSystem;
+using Lumina.Contracts.Responses.FileSystemManagement.Common;
+using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
+using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
+using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
+using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using Mediator;
using System.Collections.Generic;
using System.Linq;
@@ -14,7 +14,7 @@ using System.Threading;
using System.Threading.Tasks;
#endregion
-namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetDirectoryTree;
+namespace Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetDirectoryTree;
///
/// Handler for the query to get a directory tree.
@@ -56,7 +56,7 @@ public class GetDirectoryTreeQueryHandler : IRequestHandler> pathPartsResults = _pathService.ParsePath(request.Path);
+ ErrorOr> pathPartsResults = _pathService.ParsePath(request.Path!);
if (pathPartsResults.IsError)
return pathPartsResults.Errors;
@@ -84,7 +84,7 @@ public class GetDirectoryTreeQueryHandler : IRequestHandler> driveResult = _driveService.GetDrives();
if (driveResult.IsError)
return driveResult.Errors;
- return ErrorOrFactory.From(driveResult.Value.Adapt>());
+ return ErrorOrFactory.From(driveResult.Value.ToTreeNodeResponses());
}
///
diff --git a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectoryTree/GetDirectoryTreeQueryValidator.cs b/src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetDirectoryTree/GetDirectoryTreeQueryValidator.cs
similarity index 75%
rename from src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectoryTree/GetDirectoryTreeQueryValidator.cs
rename to src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetDirectoryTree/GetDirectoryTreeQueryValidator.cs
index 08f84bc3..13229211 100644
--- a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectoryTree/GetDirectoryTreeQueryValidator.cs
+++ b/src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetDirectoryTree/GetDirectoryTreeQueryValidator.cs
@@ -3,7 +3,7 @@ using FluentValidation;
using Lumina.Domain.Common.Errors;
#endregion
-namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetDirectoryTree;
+namespace Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetDirectoryTree;
///
/// Validates the needed validation rules for .
@@ -15,6 +15,6 @@ public class GetDirectoryTreeQueryValidator : AbstractValidator
public GetDirectoryTreeQueryValidator()
{
- RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileManagement.PathCannotBeEmpty.Code);
+ RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
}
}
\ No newline at end of file
diff --git a/src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetTreeDirectories/GetTreeDirectoriesQuery.cs b/src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetTreeDirectories/GetTreeDirectoriesQuery.cs
new file mode 100644
index 00000000..3157cce9
--- /dev/null
+++ b/src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetTreeDirectories/GetTreeDirectoriesQuery.cs
@@ -0,0 +1,20 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Contracts.Responses.FileSystemManagement.Common;
+using Mediator;
+using System.Collections.Generic;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetTreeDirectories;
+
+///
+/// Query for retrieving the list of directories at a path.
+///
+/// The path for which to retrieve the list of directories.
+/// Whether to include hidden directories or not.
+[DebuggerDisplay("Path: {Path}")]
+public record GetTreeDirectoriesQuery(
+ string? Path,
+ bool IncludeHiddenElements
+) : IRequest>>;
diff --git a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetTreeDirectories/GetTreeDirectoriesQueryHandler.cs b/src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetTreeDirectories/GetTreeDirectoriesQueryHandler.cs
similarity index 71%
rename from src/Lumina.Application/Core/FileManagement/Directories/Queries/GetTreeDirectories/GetTreeDirectoriesQueryHandler.cs
rename to src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetTreeDirectories/GetTreeDirectoriesQueryHandler.cs
index 6f301850..1e46d6a3 100644
--- a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetTreeDirectories/GetTreeDirectoriesQueryHandler.cs
+++ b/src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetTreeDirectories/GetTreeDirectoriesQueryHandler.cs
@@ -1,17 +1,16 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
-using Lumina.Contracts.Responses.FileManagement;
-using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
-using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
-using Mapster;
-using MapsterMapper;
+using Lumina.Application.Common.Mapping.FileSystemManagement.Directories;
+using Lumina.Contracts.Responses.FileSystemManagement.Common;
+using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
+using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
using Mediator;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
#endregion
-namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetTreeDirectories;
+namespace Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetTreeDirectories;
///
/// Handler for the query to get all directories.
@@ -19,17 +18,14 @@ namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetTreeDire
public class GetTreeDirectoriesQueryHandler : IRequestHandler>>
{
private readonly IDirectoryService _directoryService;
- private readonly IMapper _mapper;
///
/// Initializes a new instance of the class.
///
/// Injected service for handling directories.
- /// Injected service for mapping objects.
- public GetTreeDirectoriesQueryHandler(IDirectoryService directoryService, IMapper mapper)
+ public GetTreeDirectoriesQueryHandler(IDirectoryService directoryService)
{
_directoryService = directoryService;
- _mapper = mapper;
}
///
@@ -42,7 +38,7 @@ public class GetTreeDirectoriesQueryHandler : IRequestHandler
public ValueTask>> Handle(GetTreeDirectoriesQuery request, CancellationToken cancellationToken)
{
- ErrorOr> result = _directoryService.GetSubdirectories(request.Path, request.IncludeHiddenElements);
- return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(_mapper.Map>(values)), errors => errors));
+ ErrorOr> result = _directoryService.GetSubdirectories(request.Path!, request.IncludeHiddenElements);
+ return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(values.ToFileSystemTreeNodeResponses()), errors => errors));
}
}
diff --git a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetTreeDirectories/GetTreeDirectoriesQueryValidator.cs b/src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetTreeDirectories/GetTreeDirectoriesQueryValidator.cs
similarity index 75%
rename from src/Lumina.Application/Core/FileManagement/Directories/Queries/GetTreeDirectories/GetTreeDirectoriesQueryValidator.cs
rename to src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetTreeDirectories/GetTreeDirectoriesQueryValidator.cs
index 7d2feb18..42963faa 100644
--- a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetTreeDirectories/GetTreeDirectoriesQueryValidator.cs
+++ b/src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetTreeDirectories/GetTreeDirectoriesQueryValidator.cs
@@ -3,7 +3,7 @@ using FluentValidation;
using Lumina.Domain.Common.Errors;
#endregion
-namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetTreeDirectories;
+namespace Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetTreeDirectories;
///
/// Validates the needed validation rules for .
@@ -15,6 +15,6 @@ public class GetTreeDirectoriesQueryValidator : AbstractValidator
public GetTreeDirectoriesQueryValidator()
{
- RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileManagement.PathCannotBeEmpty.Code);
+ RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
}
}
\ No newline at end of file
diff --git a/src/Lumina.Application/Core/FileManagement/Drives/Queries/GetDrives/GetDrivesQuery.cs b/src/Lumina.Application/Core/FileSystemManagement/Drives/Queries/GetDrives/GetDrivesQuery.cs
similarity index 74%
rename from src/Lumina.Application/Core/FileManagement/Drives/Queries/GetDrives/GetDrivesQuery.cs
rename to src/Lumina.Application/Core/FileSystemManagement/Drives/Queries/GetDrives/GetDrivesQuery.cs
index b1e0269e..74b2c0b0 100644
--- a/src/Lumina.Application/Core/FileManagement/Drives/Queries/GetDrives/GetDrivesQuery.cs
+++ b/src/Lumina.Application/Core/FileSystemManagement/Drives/Queries/GetDrives/GetDrivesQuery.cs
@@ -1,11 +1,11 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
-using Lumina.Contracts.Responses.FileManagement;
+using Lumina.Contracts.Responses.FileSystemManagement.Common;
using Mediator;
using System.Collections.Generic;
#endregion
-namespace Lumina.Application.Core.FileManagement.Drives.Queries.GetDrives;
+namespace Lumina.Application.Core.FileSystemManagement.Drives.Queries.GetDrives;
///
/// Query for retrieving the list of drives.
diff --git a/src/Lumina.Application/Core/FileManagement/Drives/Queries/GetDrives/GetDrivesQueryHandler.cs b/src/Lumina.Application/Core/FileSystemManagement/Drives/Queries/GetDrives/GetDrivesQueryHandler.cs
similarity index 71%
rename from src/Lumina.Application/Core/FileManagement/Drives/Queries/GetDrives/GetDrivesQueryHandler.cs
rename to src/Lumina.Application/Core/FileSystemManagement/Drives/Queries/GetDrives/GetDrivesQueryHandler.cs
index 5246948d..06591796 100644
--- a/src/Lumina.Application/Core/FileManagement/Drives/Queries/GetDrives/GetDrivesQueryHandler.cs
+++ b/src/Lumina.Application/Core/FileSystemManagement/Drives/Queries/GetDrives/GetDrivesQueryHandler.cs
@@ -1,17 +1,16 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
-using Lumina.Contracts.Responses.FileManagement;
-using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate;
-using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
-using Mapster;
-using MapsterMapper;
+using Lumina.Application.Common.Mapping.FileSystemManagement.FileSystem;
+using Lumina.Contracts.Responses.FileSystemManagement.Common;
+using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
+using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
using Mediator;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
#endregion
-namespace Lumina.Application.Core.FileManagement.Drives.Queries.GetDrives;
+namespace Lumina.Application.Core.FileSystemManagement.Drives.Queries.GetDrives;
///
/// Handler for the query to get all drives.
@@ -19,17 +18,14 @@ namespace Lumina.Application.Core.FileManagement.Drives.Queries.GetDrives;
public class GetDrivesQueryHandler : IRequestHandler>>
{
private readonly IDriveService _driveService;
- private readonly IMapper _mapper;
///
/// Initializes a new instance of the class.
///
/// Injected service for handling file system drives.
- /// Injected service for mapping objects.
- public GetDrivesQueryHandler(IDriveService driveService, IMapper mapper)
+ public GetDrivesQueryHandler(IDriveService driveService)
{
_driveService = driveService;
- _mapper = mapper;
}
///
@@ -43,6 +39,6 @@ public class GetDrivesQueryHandler : IRequestHandler>> Handle(GetDrivesQuery request, CancellationToken cancellationToken)
{
ErrorOr> result = _driveService.GetDrives();
- return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(_mapper.Map>(values)), errors => errors));
+ return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(values.ToTreeNodeResponses()), errors => errors));
}
}
diff --git a/src/Lumina.Application/Core/FileManagement/FileSystem/Queries/GetFileSystem/GetFileSystemQuery.cs b/src/Lumina.Application/Core/FileSystemManagement/FileSystem/Queries/GetFileSystem/GetFileSystemQuery.cs
similarity index 69%
rename from src/Lumina.Application/Core/FileManagement/FileSystem/Queries/GetFileSystem/GetFileSystemQuery.cs
rename to src/Lumina.Application/Core/FileSystemManagement/FileSystem/Queries/GetFileSystem/GetFileSystemQuery.cs
index e4356d59..512394b6 100644
--- a/src/Lumina.Application/Core/FileManagement/FileSystem/Queries/GetFileSystem/GetFileSystemQuery.cs
+++ b/src/Lumina.Application/Core/FileSystemManagement/FileSystem/Queries/GetFileSystem/GetFileSystemQuery.cs
@@ -1,9 +1,9 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Contracts.Responses.FileManagement;
+using Lumina.Contracts.Responses.FileSystemManagement.FileSystem;
using Mediator;
#endregion
-namespace Lumina.Application.Core.FileManagement.FileSystem.Queries.GetFileSystem;
+namespace Lumina.Application.Core.FileSystemManagement.FileSystem.Queries.GetFileSystem;
///
/// Query for retrieving the file system type.
diff --git a/src/Lumina.Application/Core/FileManagement/FileSystem/Queries/GetFileSystem/GetFileSystemQueryHandler.cs b/src/Lumina.Application/Core/FileSystemManagement/FileSystem/Queries/GetFileSystem/GetFileSystemQueryHandler.cs
similarity index 83%
rename from src/Lumina.Application/Core/FileManagement/FileSystem/Queries/GetFileSystem/GetFileSystemQueryHandler.cs
rename to src/Lumina.Application/Core/FileSystemManagement/FileSystem/Queries/GetFileSystem/GetFileSystemQueryHandler.cs
index bba396b2..255cafcd 100644
--- a/src/Lumina.Application/Core/FileManagement/FileSystem/Queries/GetFileSystem/GetFileSystemQueryHandler.cs
+++ b/src/Lumina.Application/Core/FileSystemManagement/FileSystem/Queries/GetFileSystem/GetFileSystemQueryHandler.cs
@@ -1,12 +1,12 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Contracts.Responses.FileManagement;
-using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
+using Lumina.Contracts.Responses.FileSystemManagement.FileSystem;
+using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
using Mediator;
using System.Threading;
using System.Threading.Tasks;
#endregion
-namespace Lumina.Application.Core.FileManagement.FileSystem.Queries.GetFileSystem;
+namespace Lumina.Application.Core.FileSystemManagement.FileSystem.Queries.GetFileSystem;
///
/// Handler for the query to get the file system type.
diff --git a/src/Lumina.Application/Core/FileSystemManagement/Files/Queries/GetFiles/GetFilesQuery.cs b/src/Lumina.Application/Core/FileSystemManagement/Files/Queries/GetFiles/GetFilesQuery.cs
new file mode 100644
index 00000000..52fc745b
--- /dev/null
+++ b/src/Lumina.Application/Core/FileSystemManagement/Files/Queries/GetFiles/GetFilesQuery.cs
@@ -0,0 +1,20 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Contracts.Responses.FileSystemManagement.Files;
+using Mediator;
+using System.Collections.Generic;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Core.FileSystemManagement.Files.Queries.GetFiles;
+
+///
+/// Query for retrieving the list of files at a path.
+///
+/// The path for which to retrieve the list of files.
+/// Whether to include hidden files and directories or not.
+[DebuggerDisplay("Path: {Path}")]
+public record GetFilesQuery(
+ string? Path,
+ bool IncludeHiddenElements
+) : IRequest>>;
diff --git a/src/Lumina.Application/Core/FileManagement/Files/Queries/GetFiles/GetFilesQueryHandler.cs b/src/Lumina.Application/Core/FileSystemManagement/Files/Queries/GetFiles/GetFilesQueryHandler.cs
similarity index 68%
rename from src/Lumina.Application/Core/FileManagement/Files/Queries/GetFiles/GetFilesQueryHandler.cs
rename to src/Lumina.Application/Core/FileSystemManagement/Files/Queries/GetFiles/GetFilesQueryHandler.cs
index 750e7848..57e79a1b 100644
--- a/src/Lumina.Application/Core/FileManagement/Files/Queries/GetFiles/GetFilesQueryHandler.cs
+++ b/src/Lumina.Application/Core/FileSystemManagement/Files/Queries/GetFiles/GetFilesQueryHandler.cs
@@ -1,17 +1,16 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
-using Lumina.Contracts.Responses.FileManagement;
-using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
-using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
-using Mapster;
-using MapsterMapper;
+using Lumina.Application.Common.Mapping.FileSystemManagement.Files;
+using Lumina.Contracts.Responses.FileSystemManagement.Files;
+using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
+using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
using Mediator;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
#endregion
-namespace Lumina.Application.Core.FileManagement.Files.Queries.GetFiles;
+namespace Lumina.Application.Core.FileSystemManagement.Files.Queries.GetFiles;
///
/// Handler for the query to get all files.
@@ -19,17 +18,14 @@ namespace Lumina.Application.Core.FileManagement.Files.Queries.GetFiles;
public class GetFilesQueryHandler : IRequestHandler>>
{
private readonly IFileService _fileService;
- private readonly IMapper _mapper;
///
/// Initializes a new instance of the class.
///
/// Injected service for handling files.
- /// Injected service for mapping objects.
- public GetFilesQueryHandler(IFileService fileService, IMapper mapper)
+ public GetFilesQueryHandler(IFileService fileService)
{
_fileService = fileService;
- _mapper = mapper;
}
///
@@ -42,7 +38,7 @@ public class GetFilesQueryHandler : IRequestHandler
public ValueTask>> Handle(GetFilesQuery request, CancellationToken cancellationToken)
{
- ErrorOr> result = _fileService.GetFiles(request.Path, request.IncludeHiddenElements);
- return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(_mapper.Map>(values)), errors => errors));
+ ErrorOr> result = _fileService.GetFiles(request.Path!, request.IncludeHiddenElements);
+ return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(values.ToResponses()), errors => errors));
}
}
diff --git a/src/Lumina.Application/Core/FileManagement/Files/Queries/GetFiles/GetFilesQueryValidator.cs b/src/Lumina.Application/Core/FileSystemManagement/Files/Queries/GetFiles/GetFilesQueryValidator.cs
similarity index 75%
rename from src/Lumina.Application/Core/FileManagement/Files/Queries/GetFiles/GetFilesQueryValidator.cs
rename to src/Lumina.Application/Core/FileSystemManagement/Files/Queries/GetFiles/GetFilesQueryValidator.cs
index f832b1c3..2b15eef1 100644
--- a/src/Lumina.Application/Core/FileManagement/Files/Queries/GetFiles/GetFilesQueryValidator.cs
+++ b/src/Lumina.Application/Core/FileSystemManagement/Files/Queries/GetFiles/GetFilesQueryValidator.cs
@@ -3,7 +3,7 @@ using FluentValidation;
using Lumina.Domain.Common.Errors;
#endregion
-namespace Lumina.Application.Core.FileManagement.Files.Queries.GetFiles;
+namespace Lumina.Application.Core.FileSystemManagement.Files.Queries.GetFiles;
///
/// Validates the needed validation rules for .
@@ -15,6 +15,6 @@ public class GetFilesQueryValidator : AbstractValidator
///
public GetFilesQueryValidator()
{
- RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileManagement.PathCannotBeEmpty.Code);
+ RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
}
}
\ No newline at end of file
diff --git a/src/Lumina.Application/Core/FileSystemManagement/Files/Queries/GetTreeFiles/GetTreeFilesQuery.cs b/src/Lumina.Application/Core/FileSystemManagement/Files/Queries/GetTreeFiles/GetTreeFilesQuery.cs
new file mode 100644
index 00000000..b31a5645
--- /dev/null
+++ b/src/Lumina.Application/Core/FileSystemManagement/Files/Queries/GetTreeFiles/GetTreeFilesQuery.cs
@@ -0,0 +1,20 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Contracts.Responses.FileSystemManagement.Common;
+using Mediator;
+using System.Collections.Generic;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Core.FileSystemManagement.Files.Queries.GetTreeFiles;
+
+///
+/// Query for retrieving the list of files at a path.
+///
+/// The path for which to retrieve the list of files.
+/// Whether to include hidden files and directories or not.
+[DebuggerDisplay("Path: {Path}")]
+public record GetTreeFilesQuery(
+ string? Path,
+ bool IncludeHiddenElements
+) : IRequest>>;
diff --git a/src/Lumina.Application/Core/FileManagement/Files/Queries/GetTreeFiles/GetTreeFilesQueryHandler.cs b/src/Lumina.Application/Core/FileSystemManagement/Files/Queries/GetTreeFiles/GetTreeFilesQueryHandler.cs
similarity index 68%
rename from src/Lumina.Application/Core/FileManagement/Files/Queries/GetTreeFiles/GetTreeFilesQueryHandler.cs
rename to src/Lumina.Application/Core/FileSystemManagement/Files/Queries/GetTreeFiles/GetTreeFilesQueryHandler.cs
index b3263ad7..6bbb0023 100644
--- a/src/Lumina.Application/Core/FileManagement/Files/Queries/GetTreeFiles/GetTreeFilesQueryHandler.cs
+++ b/src/Lumina.Application/Core/FileSystemManagement/Files/Queries/GetTreeFiles/GetTreeFilesQueryHandler.cs
@@ -1,17 +1,16 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
-using Lumina.Contracts.Responses.FileManagement;
-using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
-using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
-using Mapster;
-using MapsterMapper;
+using Lumina.Application.Common.Mapping.FileSystemManagement.Files;
+using Lumina.Contracts.Responses.FileSystemManagement.Common;
+using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
+using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
using Mediator;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
#endregion
-namespace Lumina.Application.Core.FileManagement.Files.Queries.GetTreeFiles;
+namespace Lumina.Application.Core.FileSystemManagement.Files.Queries.GetTreeFiles;
///
/// Handler for the query to get all files.
@@ -19,17 +18,14 @@ namespace Lumina.Application.Core.FileManagement.Files.Queries.GetTreeFiles;
public class GetTreeFilesQueryHandler : IRequestHandler>>
{
private readonly IFileService _fileService;
- private readonly IMapper _mapper;
///
/// Initializes a new instance of the