mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 16:11:10 +00:00
Moves repository entities to Application layer for joint access
This commit is contained in:
1 parent
baf9854355
commit
7321fb89e2
120 files changed
+2606
-784
No files matched your search
@@ -0,0 +1,14 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a genre.
|
||||
/// </summary>
|
||||
/// <param name="Name">Gets the name of the genre.</param>
|
||||
[DebuggerDisplay("Name: {Name}")]
|
||||
public record GenreEntity(
|
||||
string? Name
|
||||
);
|
||||
@@ -0,0 +1,26 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for storage models, enforces Id.
|
||||
/// </summary>
|
||||
public interface IStorageEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the identifier of the entity.
|
||||
/// </summary>
|
||||
Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
DateTime Created { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
/// </summary>
|
||||
DateTime? Updated { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a rating.
|
||||
/// </summary>
|
||||
/// <param name="Value">Gets the rating value.</param>
|
||||
/// <param name="MaxValue">Gets the maximum possible rating value.</param>
|
||||
/// <param name="VoteCount">Gets the number of votes that contributed to the rating.</param>
|
||||
[DebuggerDisplay("{Value}/{MaxValue}")]
|
||||
public abstract record RatingEntity(
|
||||
decimal? Value,
|
||||
decimal? MaxValue,
|
||||
int? VoteCount
|
||||
);
|
||||
@@ -0,0 +1,14 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a tag.
|
||||
/// </summary>
|
||||
/// <param name="Name">Gets the name of the tag.</param>
|
||||
[DebuggerDisplay("Name: {Name}")]
|
||||
public record TagEntity(
|
||||
string? Name
|
||||
);
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.FileSystemManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Generic filesystem data transfer object.
|
||||
/// </summary>
|
||||
/// <param name="Path">The path of the file system item.</param>
|
||||
/// <param name="Name">The name of the file system item.</param>
|
||||
/// <param name="DateCreated">The creation date of the file system item.</param>
|
||||
/// <param name="DateModified">The modification date of the file system item.</param>
|
||||
[DebuggerDisplay("Name: {Name}")]
|
||||
public record FileSystemItemEntity(
|
||||
string Path,
|
||||
string Name,
|
||||
DateTime DateCreated,
|
||||
DateTime DateModified
|
||||
);
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.MediaContributors;
|
||||
|
||||
/// <summary>
|
||||
/// Repository entity for a media contributor.
|
||||
/// </summary>
|
||||
/// <param name="Name">The name details of the media contributor, including display and legal names.</param>
|
||||
/// <param name="Role">The role details of the media contributor, including the role name and category.</param>
|
||||
[DebuggerDisplay("Name: {Name}, Role: {Role}")]
|
||||
public record MediaContributorEntity(
|
||||
MediaContributorNameEntity? Name,
|
||||
MediaContributorRoleEntity? Role
|
||||
);
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.MediaContributors;
|
||||
|
||||
/// <summary>
|
||||
/// Repository entity for a media contributor name.
|
||||
/// </summary>
|
||||
/// <param name="DisplayName">The display name of the media contributor.</param>
|
||||
/// <param name="LegalName">The legal name of the media contributor.</param>
|
||||
[DebuggerDisplay("DisplayName: {DisplayName}")]
|
||||
public record MediaContributorNameEntity(
|
||||
string? DisplayName,
|
||||
string? LegalName
|
||||
);
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.MediaContributors;
|
||||
|
||||
/// <summary>
|
||||
/// Repository entity for a media contributor role.
|
||||
/// </summary>
|
||||
/// <param name="Name">The name of the role assigned to the media contributor.</param>
|
||||
/// <param name="Category">The category of the role.</param>
|
||||
[DebuggerDisplay("Name: {Name}, Category: {Category}")]
|
||||
public record MediaContributorRoleEntity(
|
||||
string? Name,
|
||||
string? Category
|
||||
);
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Repository entity for a media library content location.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("Path: {Path}")]
|
||||
public class LibraryContentLocationEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the path of the media library content location.
|
||||
/// </summary>
|
||||
public required string Path { get; set; }
|
||||
}
|
||||
+57
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Repository entity for a media library.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
public class LibraryEntity : IStorageEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id of the media library.
|
||||
/// </summary>
|
||||
public required Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Id of the user that owns the media library.
|
||||
/// </summary>
|
||||
public required Guid UserId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the title of the media library.
|
||||
/// </summary>
|
||||
public required string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the media library.
|
||||
/// </summary>
|
||||
public required LibraryType LibraryType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the list of file system paths that make up the media library.
|
||||
/// </summary>
|
||||
public required ICollection<LibraryContentLocationEntity> ContentLocations { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user that owns the media library.
|
||||
/// </summary>
|
||||
public UserEntity User { get; init; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime Created { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
/// </summary>
|
||||
public DateTime? Updated { get; set; }
|
||||
}
|
||||
+207
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Repository entity for a book.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
public class BookEntity : IStorageEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id of the media item.
|
||||
/// </summary>
|
||||
public required Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the title of the media item.
|
||||
/// </summary>
|
||||
public required string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the original title of the media item.
|
||||
/// </summary>
|
||||
public string? OriginalTitle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional description of the media item.
|
||||
/// </summary>
|
||||
public string? Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional original release date of the media item.
|
||||
/// </summary>
|
||||
public DateOnly? OriginalReleaseDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional original release year of the media item.
|
||||
/// This is useful when only the year of original release is known.
|
||||
/// </summary>
|
||||
public int? OriginalReleaseYear { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional re-release or reissue date of the media item.
|
||||
/// </summary>
|
||||
public DateOnly? ReReleaseDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional re-release or reissue year of the media item.
|
||||
/// </summary>
|
||||
public int? ReReleaseYear { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional country or region of release.
|
||||
/// </summary>
|
||||
public string? ReleaseCountry { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional release version or edition. (e.g. "Original", "Director's Cut", "2.0")
|
||||
/// </summary>
|
||||
public string? ReleaseVersion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ISO 639-1 two-letter language code.
|
||||
/// </summary>
|
||||
public string? LanguageCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the full name of the language in English.
|
||||
/// </summary>
|
||||
public string? LanguageName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an optional native name of the language.
|
||||
/// </summary>
|
||||
public string? LanguageNativeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional ISO 639-1 two-letter original language code.
|
||||
/// </summary>
|
||||
public string? OriginalLanguageCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional full name of the original language in English.
|
||||
/// </summary>
|
||||
public string? OriginalLanguageName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an optional native name of the original language.
|
||||
/// </summary>
|
||||
public string? OriginalLanguageNativeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the list of tags associated with the media item.
|
||||
/// </summary>
|
||||
public HashSet<TagEntity> Tags { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the list of genres associated with the media item.
|
||||
/// </summary>
|
||||
public HashSet<GenreEntity> Genres { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the publisher of the written content.
|
||||
/// </summary>
|
||||
public string? Publisher { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the number of pages in the written content.
|
||||
/// </summary>
|
||||
public int? PageCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the format of the book (e.g., Hardcover, Paperback), if applicable.
|
||||
/// </summary>
|
||||
public BookFormat? Format { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the edition of the book, if applicable.
|
||||
/// </summary>
|
||||
public string? Edition { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the volume or book number in the series, if applicable.
|
||||
/// </summary>
|
||||
public int? VolumeNumber { get; set; }
|
||||
// TODO: uncomment when series is implemented
|
||||
/// <summary>
|
||||
/// Gets or sets the series id, if the book is part of a series.
|
||||
/// </summary>
|
||||
//public Guid? BookSeriesId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ASIN (Amazon Standard Identification Number) of the book.
|
||||
/// </summary>
|
||||
public string? ASIN { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Goodreads ID of the book.
|
||||
/// </summary>
|
||||
public string? GoodreadsId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Library of Congress Control Number (LCCN) of the book.
|
||||
/// </summary>
|
||||
public string? LCCN { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the OCLC Number (WorldCat identifier) of the book.
|
||||
/// </summary>
|
||||
public string? OCLCNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Open Library ID of the book.
|
||||
/// </summary>
|
||||
public string? OpenLibraryId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the LibraryThing ID of the book.
|
||||
/// </summary>
|
||||
public string? LibraryThingId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Google Books ID of the book.
|
||||
/// </summary>
|
||||
public string? GoogleBooksId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Barnes & Noble ID of the book.
|
||||
/// </summary>
|
||||
public string? BarnesAndNobleId { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Apple Books ID of the book.
|
||||
/// </summary>
|
||||
public string? AppleBooksId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the list of ISBN (International Standard Book Number) of the book.
|
||||
/// </summary>
|
||||
public List<IsbnEntity> ISBNs { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the list of media contributors (actors, directors, etc) starring in this book.
|
||||
/// </summary>
|
||||
//public List<ContributorIdModel> ContributorIds { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the list of ratings for this book.
|
||||
/// </summary>
|
||||
public List<BookRatingEntity> Ratings { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime Created { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
/// </summary>
|
||||
public DateTime? Updated { get; set; }
|
||||
}
|
||||
+22
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Repository entity for a book rating.
|
||||
/// </summary>
|
||||
/// <param name="Value">The rating value for the book.</param>
|
||||
/// <param name="MaxValue">The maximum possible rating value for the book.</param>
|
||||
/// <param name="Source">The source of the book rating (e.g., a specific website or platform).</param>
|
||||
/// <param name="VoteCount">The number of votes that contributed to the book rating.</param>
|
||||
[DebuggerDisplay("{Value}/{MaxValue}")]
|
||||
public record BookRatingEntity(
|
||||
decimal? Value,
|
||||
decimal? MaxValue,
|
||||
BookRatingSource? Source,
|
||||
int? VoteCount
|
||||
) : RatingEntity(Value, MaxValue, VoteCount);
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Repository entity for book series.
|
||||
/// </summary>
|
||||
/// <param name="Title">The title of the book series.</param>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
public record BookSeriesEntity(
|
||||
string? Title
|
||||
);
|
||||
+17
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Repository entity for ISBN information.
|
||||
/// </summary>
|
||||
/// <param name="Value">The ISBN value.</param>
|
||||
/// <param name="Format">The format of the ISBN (e.g., ISBN-10 or ISBN-13).</param>
|
||||
[DebuggerDisplay("ISBN: {Value} ({Format})")]
|
||||
public record IsbnEntity(
|
||||
string? Value,
|
||||
IsbnFormat? Format
|
||||
);
|
||||
@@ -0,0 +1,61 @@
|
||||
#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;
|
||||
|
||||
/// <summary>
|
||||
/// Repository entity for a user.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("Username: {Username}")]
|
||||
public class UserEntity : IStorageEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id of the user.
|
||||
/// </summary>
|
||||
public required Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the username of the user.
|
||||
/// </summary>
|
||||
public required string Username { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the hashed password of the user.
|
||||
/// </summary>
|
||||
public required string Password { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Time-based One-Time Password (TOTP) secret for two-factor authentication.
|
||||
/// </summary>
|
||||
public string? TotpSecret { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional token used for account verification or password reset.
|
||||
/// </summary>
|
||||
public string? VerificationToken { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional date and time when the verification token was created.
|
||||
/// </summary>
|
||||
public DateTime? VerificationTokenCreated { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of libraries owned by this user.
|
||||
/// </summary>
|
||||
public required ICollection<LibraryEntity> Libraries { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime Created { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the optional time and date when the entity was updated.
|
||||
/// </summary>
|
||||
public DateTime? Updated { get; set; }
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
|
||||
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Repositories.Books;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
|
||||
using Lumina.Contracts.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
|
||||
using Lumina.Contracts.Entities.UsersManagement;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Repositories.Users;
|
||||
|
||||
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GenreDto"/>.
|
||||
/// </summary>
|
||||
public static class GenreDtoMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="dto"/> to <see cref="GenreDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="dto">The DTO to be converted.</param>
|
||||
/// <returns>The converted domain entity.</returns>
|
||||
public static ErrorOr<Genre> ToDomainEntity(this GenreDto dto)
|
||||
{
|
||||
return Genre.Create(
|
||||
dto.Name
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="dtos"/> to a collection of <see cref="Genre"/>.
|
||||
/// </summary>
|
||||
/// <param name="dtos">The DTOs to be converted.</param>
|
||||
/// <returns>The converted domain entities.</returns>
|
||||
public static IEnumerable<ErrorOr<Genre>> ToDomainEntities(this IEnumerable<GenreDto> dtos)
|
||||
{
|
||||
return dtos.Select(repositoryEntity => repositoryEntity.ToDomainEntity());
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
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;
|
||||
@@ -14,14 +15,36 @@ namespace Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
public static class GenreEntityMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="GenreEntity"/>.
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="GenreDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>The converted DTO.</returns>
|
||||
public static GenreDto ToResponse(this GenreEntity repositoryEntity)
|
||||
{
|
||||
return new GenreDto(
|
||||
repositoryEntity.Name ?? default
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="GenreDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository entities to be converted.</param>
|
||||
/// <returns>The converted DTOs.</returns>
|
||||
public static IEnumerable<GenreDto> ToResponses(this IEnumerable<GenreEntity> repositoryEntities)
|
||||
{
|
||||
return repositoryEntities.Select(responseEntity => responseEntity.ToResponse());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="Genre"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>The converted domain entity.</returns>
|
||||
public static ErrorOr<Genre> ToDomainEntity(this GenreEntity repositoryEntity)
|
||||
{
|
||||
return Genre.Create(
|
||||
repositoryEntity.Name
|
||||
repositoryEntity.Name ?? default
|
||||
);
|
||||
}
|
||||
|
||||
@@ -32,6 +55,6 @@ public static class GenreEntityMapping
|
||||
/// <returns>The converted domain entities.</returns>
|
||||
public static IEnumerable<ErrorOr<Genre>> ToDomainEntities(this IEnumerable<GenreEntity> repositoryEntities)
|
||||
{
|
||||
return repositoryEntities.Select(repositoryEntity => repositoryEntity.ToDomainEntity());
|
||||
return repositoryEntities.Select(domainEntity => domainEntity.ToDomainEntity());
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="TagDto"/>.
|
||||
/// </summary>
|
||||
public static class TagDtoMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="dto"/> to <see cref="Tag"/>.
|
||||
/// </summary>
|
||||
/// <param name="dto">The DTO to be converted.</param>
|
||||
/// <returns>The converted domain entity.</returns>
|
||||
public static ErrorOr<Tag> ToDomainEntity(this TagDto dto)
|
||||
{
|
||||
return Tag.Create(
|
||||
dto.Name
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="dtos"/> to a collection of <see cref="Tag"/>.
|
||||
/// </summary>
|
||||
/// <param name="dtos">The DTOs to be converted.</param>
|
||||
/// <returns>The converted domain entities.</returns>
|
||||
public static IEnumerable<ErrorOr<Tag>> ToDomainEntities(this IEnumerable<TagDto> dtos)
|
||||
{
|
||||
return dtos.Select(domainEntity => domainEntity.ToDomainEntity());
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
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;
|
||||
@@ -13,6 +14,28 @@ namespace Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
/// </summary>
|
||||
public static class TagEntityMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="TagDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>The converted DTO.</returns>
|
||||
public static TagDto ToResponse(this TagEntity repositoryEntity)
|
||||
{
|
||||
return new TagDto(
|
||||
repositoryEntity.Name ?? default
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="TagDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository entities to be converted.</param>
|
||||
/// <returns>The converted DTOs.</returns>
|
||||
public static IEnumerable<TagDto> ToResponses(this IEnumerable<TagEntity> repositoryEntities)
|
||||
{
|
||||
return repositoryEntities.Select(responseEntity => responseEntity.ToResponse());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="Tag"/>.
|
||||
/// </summary>
|
||||
@@ -21,7 +44,7 @@ public static class TagEntityMapping
|
||||
public static ErrorOr<Tag> ToDomainEntity(this TagEntity repositoryEntity)
|
||||
{
|
||||
return Tag.Create(
|
||||
repositoryEntity.Name
|
||||
repositoryEntity.Name ?? default
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ public static class DirectoryMapping
|
||||
domainEntity.Name,
|
||||
domainEntity.DateCreated.Value,
|
||||
domainEntity.DateModified.Value,
|
||||
domainEntity.Items.Select(fileSystemItem => fileSystemItem.ToFileSystemItemEntity())
|
||||
domainEntity.Items.Select(fileSystemItem => fileSystemItem.ToFileSystemItemDto())
|
||||
.ToList()
|
||||
);
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,13 +1,13 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Directories;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Files;
|
||||
using Lumina.Contracts.Entities.FileSystemManagement;
|
||||
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;
|
||||
@@ -18,13 +18,13 @@ namespace Lumina.Application.Common.Mapping.FileSystemManagement.FileSystem;
|
||||
public static class FileSystemItemMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainEntity"/> to <see cref="FileSystemItemEntity"/>.
|
||||
/// Converts <paramref name="domainEntity"/> to <see cref="FileSystemItemDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainEntity">The domain entity to be converted.</param>
|
||||
/// <returns>The converted entity.</returns>
|
||||
public static FileSystemItemEntity ToFileSystemItemEntity(this FileSystemItem domainEntity)
|
||||
/// <returns>The converted Dto.</returns>
|
||||
public static FileSystemItemDto ToFileSystemItemDto(this FileSystemItem domainEntity)
|
||||
{
|
||||
return new FileSystemItemEntity(
|
||||
return new FileSystemItemDto(
|
||||
domainEntity.Id.Path,
|
||||
domainEntity.Name,
|
||||
DateTime.Now,
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ namespace Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="CheckPathExistsRequest"/>.
|
||||
/// </summary>
|
||||
public static class CheckPathExistsQueryMapping
|
||||
public static class CheckPathExistsRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="CheckPathExistsQuery"/>.
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
+14
-14
@@ -1,13 +1,13 @@
|
||||
#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.Entities.Common;
|
||||
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary;
|
||||
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.Common.Enums.BookLibrary;
|
||||
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;
|
||||
@@ -151,7 +151,7 @@ public static class BookEntityMapping
|
||||
/// <returns>The converted response entity.</returns>
|
||||
public static BookResponse ToResponse(this BookEntity repositoryEntity)
|
||||
{
|
||||
ReleaseInfoEntity releaseInfoEntity = new(
|
||||
ReleaseInfoDto releaseInfoEntity = new(
|
||||
repositoryEntity.OriginalReleaseDate,
|
||||
repositoryEntity.OriginalReleaseYear,
|
||||
repositoryEntity.ReReleaseDate,
|
||||
@@ -160,29 +160,29 @@ public static class BookEntityMapping
|
||||
repositoryEntity.ReleaseVersion
|
||||
);
|
||||
// language and original language make sense only if their subproperties have values
|
||||
LanguageInfoEntity? languageInfoEntity = !string.IsNullOrWhiteSpace(repositoryEntity.LanguageCode) ||
|
||||
LanguageInfoDto? languageInfoEntity = !string.IsNullOrWhiteSpace(repositoryEntity.LanguageCode) ||
|
||||
!string.IsNullOrWhiteSpace(repositoryEntity.LanguageName) ||
|
||||
!string.IsNullOrWhiteSpace(repositoryEntity.LanguageNativeName)
|
||||
? new LanguageInfoEntity(
|
||||
? new LanguageInfoDto(
|
||||
repositoryEntity.LanguageCode,
|
||||
repositoryEntity.LanguageName,
|
||||
repositoryEntity.LanguageNativeName
|
||||
) : null;
|
||||
LanguageInfoEntity? originalLanguageInfoEntity = !string.IsNullOrWhiteSpace(repositoryEntity.OriginalLanguageCode) ||
|
||||
LanguageInfoDto? originalLanguageInfoEntity = !string.IsNullOrWhiteSpace(repositoryEntity.OriginalLanguageCode) ||
|
||||
!string.IsNullOrWhiteSpace(repositoryEntity.OriginalLanguageName) ||
|
||||
!string.IsNullOrWhiteSpace(repositoryEntity.OriginalLanguageNativeName)
|
||||
? new LanguageInfoEntity(
|
||||
? new LanguageInfoDto(
|
||||
repositoryEntity.OriginalLanguageCode,
|
||||
repositoryEntity.OriginalLanguageName,
|
||||
repositoryEntity.OriginalLanguageNativeName
|
||||
) : null;
|
||||
WrittenContentMetadataEntity metadata = new(
|
||||
WrittenContentMetadataDto metadata = new(
|
||||
repositoryEntity.Title,
|
||||
repositoryEntity.OriginalTitle,
|
||||
repositoryEntity.Description,
|
||||
releaseInfoEntity,
|
||||
[.. repositoryEntity.Genres],
|
||||
[.. repositoryEntity.Tags],
|
||||
[.. repositoryEntity.Genres.ToResponses()],
|
||||
[.. repositoryEntity.Tags.ToResponses()],
|
||||
languageInfoEntity,
|
||||
originalLanguageInfoEntity,
|
||||
repositoryEntity.Publisher,
|
||||
@@ -204,9 +204,9 @@ public static class BookEntityMapping
|
||||
repositoryEntity.GoogleBooksId,
|
||||
repositoryEntity.BarnesAndNobleId,
|
||||
repositoryEntity.AppleBooksId,
|
||||
repositoryEntity.ISBNs,
|
||||
[.. repositoryEntity.ISBNs.ToResponses()],
|
||||
null,
|
||||
repositoryEntity.Ratings,
|
||||
[.. repositoryEntity.Ratings.ToResponses()],
|
||||
repositoryEntity.Created,
|
||||
repositoryEntity.Updated
|
||||
);
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#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.Contracts.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
+42
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="BookRatingDto"/>.
|
||||
/// </summary>
|
||||
public static class BookRatingDtoMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="dto"/> to <see cref="BookRating"/>.
|
||||
/// </summary>
|
||||
/// <param name="dto">The DTO to be converted.</param>
|
||||
/// <returns>The converted domain entity.</returns>
|
||||
public static ErrorOr<BookRating> ToDomainEntity(this BookRatingDto dto)
|
||||
{
|
||||
return BookRating.Create(
|
||||
dto.Value ?? default,
|
||||
dto.MaxValue ?? default,
|
||||
Optional<BookRatingSource>.FromNullable(dto.Source),
|
||||
Optional<int>.FromNullable(dto.VoteCount)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="dtos"/> to a collection of <see cref="BookRating"/>.
|
||||
/// </summary>
|
||||
/// <param name="dtos">The DTOs to be converted.</param>
|
||||
/// <returns>The converted domain entities.</returns>
|
||||
public static IEnumerable<ErrorOr<BookRating>> ToDomainEntities(this IEnumerable<BookRatingDto> dtos)
|
||||
{
|
||||
return dtos.Select(domainEntity => domainEntity.ToDomainEntity());
|
||||
}
|
||||
}
|
||||
+27
-1
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
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;
|
||||
@@ -15,6 +16,31 @@ namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.B
|
||||
/// </summary>
|
||||
public static class BookRatingEntityMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="BookRatingDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>The converted DTO.</returns>
|
||||
public static BookRatingDto ToResponse(this BookRatingEntity repositoryEntity)
|
||||
{
|
||||
return new BookRatingDto(
|
||||
repositoryEntity.Value ?? default,
|
||||
repositoryEntity.MaxValue ?? default,
|
||||
repositoryEntity.Source,
|
||||
repositoryEntity.VoteCount
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="BookRatingDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository entities to be converted.</param>
|
||||
/// <returns>The converted DTOs.</returns>
|
||||
public static IEnumerable<BookRatingDto> ToResponses(this IEnumerable<BookRatingEntity> repositoryEntities)
|
||||
{
|
||||
return repositoryEntities.Select(responseEntity => responseEntity.ToResponse());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="BookRating"/>.
|
||||
/// </summary>
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
+41
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="IsbnDto"/>.
|
||||
/// </summary>
|
||||
public static class IsbnDtoMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="dto"/> to <see cref="Isbn"/>.
|
||||
/// </summary>
|
||||
/// <param name="dto">The DTO to be converted.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully converted <see cref="Isbn"/>, or an error message.
|
||||
/// </returns>
|
||||
public static ErrorOr<Isbn> ToDomainEntity(this IsbnDto dto)
|
||||
{
|
||||
return Isbn.Create(
|
||||
dto.Value,
|
||||
dto.Format ?? IsbnFormat.Isbn13
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="dtos"/> to a collection of <see cref="Isbn"/>.
|
||||
/// </summary>
|
||||
/// <param name="dtos">The DTOs to be converted.</param>
|
||||
/// <returns>The converted domain entities.</returns>
|
||||
public static IEnumerable<ErrorOr<Isbn>> ToDomainEntities(this IEnumerable<IsbnDto> dtos)
|
||||
{
|
||||
return dtos.Select(domainEntity => domainEntity.ToDomainEntity());
|
||||
}
|
||||
}
|
||||
+28
-7
@@ -1,7 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.Common.Enums.BookLibrary;
|
||||
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;
|
||||
@@ -14,18 +14,39 @@ namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.B
|
||||
/// </summary>
|
||||
public static class IsbnEntityMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="IsbnDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>The converted DTO.</returns>
|
||||
public static IsbnDto ToResponse(this IsbnEntity repositoryEntity)
|
||||
{
|
||||
return new IsbnDto(
|
||||
repositoryEntity.Value ?? default,
|
||||
repositoryEntity.Format ?? null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="IsbnDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository entities to be converted.</param>
|
||||
/// <returns>The converted DTOs.</returns>
|
||||
public static IEnumerable<IsbnDto> ToResponses(this IEnumerable<IsbnEntity> repositoryEntities)
|
||||
{
|
||||
return repositoryEntities.Select(responseEntity => responseEntity.ToResponse());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="Isbn"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully converted <see cref="Isbn"/>, or an error message.
|
||||
/// </returns>
|
||||
/// <returns>The converted domain entity.</returns>
|
||||
public static ErrorOr<Isbn> ToDomainEntity(this IsbnEntity repositoryEntity)
|
||||
{
|
||||
return Isbn.Create(
|
||||
repositoryEntity.Value,
|
||||
repositoryEntity.Format ?? IsbnFormat.Isbn13
|
||||
repositoryEntity.Value ?? default,
|
||||
repositoryEntity.Format ?? default
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Entities.UsersManagement;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Contracts.Responses.UsersManagement.Users;
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Entities.UsersManagement;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate;
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in new issue
Block a user