Moves repository entities to Application layer for joint access

This commit is contained in:
BinaryAlley committed 2024-11-04 19:40:11 +02:00
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
);
@@ -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
);
@@ -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
);
@@ -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
);
@@ -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
);
@@ -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; }
}
@@ -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; }
}
@@ -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; }
}
@@ -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);
@@ -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
);
@@ -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; }
}