From 50c15cf8898c5a83d41924ffa05de1e2b81a1636 Mon Sep 17 00:00:00 2001 From: Binary Alley Date: Fri, 23 Aug 2024 10:07:04 +0300 Subject: [PATCH] Continues core Domain structure modeling --- docs/technical/Aggregates.VideoLibrary.md | 71 ++++ .../Aggregates.WrittenContentLibrary.md | 196 ++++++++++ docs/technical/UbiquitousLanguage.md | 51 +++ .../Common/Enums/AudioRatingSource.cs | 27 ++ src/Lumina.Domain/Common/Enums/BookFormat.cs | 67 ++++ .../Common/Enums/BookRatingSource.cs | 27 ++ src/Lumina.Domain/Common/Enums/IsbnFormat.cs | 19 + .../Common/Enums/MediaContributorRole.cs | 17 +- .../Common/Enums/RatingSource.cs | 13 - .../Common/Enums/VideoRatingSource.cs | 32 ++ .../Common/Errors/Errors.WrittenContent.cs | 21 ++ .../Common/Models/Core/AggregateRoot.cs | 9 +- .../Common/Models/Core/AggregateRootId.cs | 3 + .../Common/Models/Core/Entity.cs | 8 +- .../Common/Primitives/Optional.cs | 9 +- .../ValueObjects/Media/MediaContributor.cs | 54 --- .../ValueObjects/Metadata/BaseMetadata.cs | 66 ++-- .../Common/ValueObjects/Metadata/Genre.cs | 4 +- .../ValueObjects/Metadata/LanguageInfo.cs | 4 +- .../Common/ValueObjects/Metadata/Rating.cs | 10 +- .../ValueObjects/Metadata/ReleaseInfo.cs | 22 +- .../Common/ValueObjects/Metadata/Tag.cs | 4 +- .../ValueObjects/AudioMetadata.cs | 158 ++++++++ .../ValueObjects/FileInfo.cs | 6 +- .../ValueObjects/StreamInfo.cs | 28 +- .../MediaContributor.cs | 100 ++++++ .../ValueObjects/ContributorName.cs | 61 ++++ .../ValueObjects/MediaContributorId.cs | 55 +++ .../MovieLibraryAggregate/Movie.cs | 101 ++++++ .../Services/IMovieLibraryService.cs | 14 + .../Services/MovieLibraryService.cs | 14 + .../ValueObjects/MovieId.cs | 55 +++ .../ValueObjects}/VideoMetadata.cs | 61 ++-- .../Services/IVideoLibraryService.cs | 24 ++ .../Services/VideoLibraryService.cs | 40 +++ .../Entities/Episode.cs | 16 + .../TvShowLibraryAggregate/Entities/Season.cs | 16 + .../Services/ITvShowLibraryService.cs | 15 + .../Services/TvShowLibraryService.cs | 17 + .../TvShowLibraryAggregate/TvShow.cs | 16 + .../ValueObjects/EpisodeId.cs | 55 +++ .../ValueObjects/SeasonId.cs} | 28 +- .../ValueObjects/TvShowId.cs | 55 +++ .../BookLibraryAggregate/Book.cs | 336 ++++++++++++++++++ .../Services/BookLibraryService.cs | 17 + .../Services/IBookLibraryService.cs | 23 ++ .../ValueObjects/BookId.cs | 55 +++ .../ValueObjects/BookLibraryId.cs | 56 +++ .../BookLibraryAggregate/ValueObjects/Isbn.cs | 136 +++++++ .../ValueObjects/WrittenContentMetadata.cs | 69 ++++ .../Services/IWrittenContentLibraryService.cs | 18 + .../Services/WrittenContentLibraryService.cs | 32 ++ .../Core/Services/IMediaLibraryService.cs | 29 ++ .../Core/Services/MediaLibraryService.cs | 37 ++ 54 files changed, 2318 insertions(+), 159 deletions(-) create mode 100644 docs/technical/Aggregates.VideoLibrary.md create mode 100644 docs/technical/Aggregates.WrittenContentLibrary.md create mode 100644 src/Lumina.Domain/Common/Enums/AudioRatingSource.cs create mode 100644 src/Lumina.Domain/Common/Enums/BookFormat.cs create mode 100644 src/Lumina.Domain/Common/Enums/BookRatingSource.cs create mode 100644 src/Lumina.Domain/Common/Enums/IsbnFormat.cs delete mode 100644 src/Lumina.Domain/Common/Enums/RatingSource.cs create mode 100644 src/Lumina.Domain/Common/Enums/VideoRatingSource.cs create mode 100644 src/Lumina.Domain/Common/Errors/Errors.WrittenContent.cs delete mode 100644 src/Lumina.Domain/Common/ValueObjects/Media/MediaContributor.cs create mode 100644 src/Lumina.Domain/Core/Aggregates/AudioLibrary/AudioLibraryAggregate/ValueObjects/AudioMetadata.cs rename src/Lumina.Domain/{ => Core/Aggregates/FileManagement}/FileManagementAggregate/ValueObjects/FileInfo.cs (93%) rename src/Lumina.Domain/{ => Core/Aggregates/FileManagement}/FileManagementAggregate/ValueObjects/StreamInfo.cs (85%) create mode 100644 src/Lumina.Domain/Core/Aggregates/MediaContributor/MediaContributorAggregate/MediaContributor.cs create mode 100644 src/Lumina.Domain/Core/Aggregates/MediaContributor/MediaContributorAggregate/ValueObjects/ContributorName.cs create mode 100644 src/Lumina.Domain/Core/Aggregates/MediaContributor/MediaContributorAggregate/ValueObjects/MediaContributorId.cs create mode 100644 src/Lumina.Domain/Core/Aggregates/VideoLibrary/MovieLibraryAggregate/Movie.cs create mode 100644 src/Lumina.Domain/Core/Aggregates/VideoLibrary/MovieLibraryAggregate/Services/IMovieLibraryService.cs create mode 100644 src/Lumina.Domain/Core/Aggregates/VideoLibrary/MovieLibraryAggregate/Services/MovieLibraryService.cs create mode 100644 src/Lumina.Domain/Core/Aggregates/VideoLibrary/MovieLibraryAggregate/ValueObjects/MovieId.cs rename src/Lumina.Domain/{Common/ValueObjects/Metadata => Core/Aggregates/VideoLibrary/MovieLibraryAggregate/ValueObjects}/VideoMetadata.cs (72%) create mode 100644 src/Lumina.Domain/Core/Aggregates/VideoLibrary/Services/IVideoLibraryService.cs create mode 100644 src/Lumina.Domain/Core/Aggregates/VideoLibrary/Services/VideoLibraryService.cs create mode 100644 src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/Entities/Episode.cs create mode 100644 src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/Entities/Season.cs create mode 100644 src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/Services/ITvShowLibraryService.cs create mode 100644 src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/Services/TvShowLibraryService.cs create mode 100644 src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/TvShow.cs create mode 100644 src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/ValueObjects/EpisodeId.cs rename src/Lumina.Domain/{Common/ValueObjects/Media/PersonId.cs => Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/ValueObjects/SeasonId.cs} (63%) create mode 100644 src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/ValueObjects/TvShowId.cs create mode 100644 src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/Book.cs create mode 100644 src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/Services/BookLibraryService.cs create mode 100644 src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/Services/IBookLibraryService.cs create mode 100644 src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/ValueObjects/BookId.cs create mode 100644 src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/ValueObjects/BookLibraryId.cs create mode 100644 src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/ValueObjects/Isbn.cs create mode 100644 src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/ValueObjects/WrittenContentMetadata.cs create mode 100644 src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/Services/IWrittenContentLibraryService.cs create mode 100644 src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/Services/WrittenContentLibraryService.cs create mode 100644 src/Lumina.Domain/Core/Services/IMediaLibraryService.cs create mode 100644 src/Lumina.Domain/Core/Services/MediaLibraryService.cs diff --git a/docs/technical/Aggregates.VideoLibrary.md b/docs/technical/Aggregates.VideoLibrary.md new file mode 100644 index 00000000..92440cf6 --- /dev/null +++ b/docs/technical/Aggregates.VideoLibrary.md @@ -0,0 +1,71 @@ +- [Lumina Domain](#lumina-domain) + - [Video Library Aggregate](#video-library-aggregate) + - [Movie](#movie) + +# [Lumina Domain](#lumina-domain) + +## [Video Library Aggregate](#video-library-aggregate) + +### [Movie](#movie) + +```csharp +class Movie +{ + ErrorOr Create(MovieId id, VideoMetadata metadata, List contributors); +} +``` + +```json +{ + "id": { "value": "00000000-0000-0000-0000-000000000000" }, + "metadata": { + "title": "The Lord of the Rings - The Fellowship of the Ring", + "originalTitle": "The Lord of the Rings - The Fellowship of the Ring", + "description": "The greatest fantasy movie ever made", + "releaseInfo": { + "originalReleaseDate": "2001-12-19", + "originalReleaseYear": 2001, + "reReleaseDate": "2024-06-08", + "reReleaseYear": 2024, + "releaseCountry": "us", + "releaseVersion": "Director's Cut" + }, + "language": { + "languageCode": "en", + "languageName": "English", + "nativeName": "English" + }, + "originalLanguage": { + "languageCode": "en", + "languageName": "English", + "nativeName": "English" + }, + "tags": [ + { "name": "epic quest" }, + { "name": "friendship" }, + { "name": "middle-earth" } + ], + "genres": [ + { "name": "fantasy" }, + { "name": "adventure" }, + { "name": "action" } + ], + "durationInSeconds": 10680, + "resolution": "3840x2160", + "frameRate": 29.97, + "videoCodec": "h.265/hevc", + "audioCodec": "FLAC" + }, + "contributors": [ + { "value": "00000000-0000-0000-0000-000000000000" } + ], + "ratings": [ + { + "value": 9.8, + "maxValue": 10.0, + "source": "TheMovieDb", + "voteCount": 1547036 + } + ] +} +``` \ No newline at end of file diff --git a/docs/technical/Aggregates.WrittenContentLibrary.md b/docs/technical/Aggregates.WrittenContentLibrary.md new file mode 100644 index 00000000..79ced4f7 --- /dev/null +++ b/docs/technical/Aggregates.WrittenContentLibrary.md @@ -0,0 +1,196 @@ +- [Lumina Domain](#lumina-domain) + - [Written Content Library Aggregate](#written-content-library-aggregate) + - [Book](#book) + +# [Lumina Domain](#lumina-domain) + +## [Written Content Library Aggregate](#written-content-library-aggregate) + +### [Book](#book) + +```csharp +class Book +{ + ErrorOr Create( + WrittenContentMetadata metadata, + BookFormat format, + Optional edition, + Optional volumeNumber, + Optional series, + Optional asin, + Optional goodreadsId, + Optional lccn, + Optional oclcNumber, + Optional openLibraryId, + Optional libraryThingId, + Optional googleBooksId, + Optional barnesAndNobleId, + Optional koboId, + Optional appleBooksId, + List isbns, + List contributors, + List ratings); +} +``` + +```json +{ + "id": { + "value": "00000000-0000-0000-0000-000000000000" + }, + "metadata": { + "title": "The Lord of the Rings: The Fellowship of the Ring", + "originalTitle": "The Fellowship of the Ring", + "description": "The first part of J.R.R. Tolkien's epic adventure The Lord of the Rings. In a sleepy village in the Shire, young Frodo Baggins finds himself faced with an immense task, as his elderly cousin Bilbo entrusts the Ring to his care. Frodo must leave his home and make a perilous journey across Middle-earth to the Cracks of Doom, there to destroy the Ring and foil the Dark Lord in his evil purpose.", + "releaseInfo": { + "originalReleaseDate": "1954-07-29", + "originalReleaseYear": 1954, + "reReleaseDate": "2001-09-06", + "reReleaseYear": 2001, + "releaseCountry": "uk", + "releaseVersion": "50th Anniversary Edition" + }, + "language": { + "languageCode": "en", + "languageName": "English", + "nativeName": "English" + }, + "originalLanguage": { + "languageCode": "en", + "languageName": "English", + "nativeName": "English" + }, + "tags": [ + { "name": "epic fantasy" }, + { "name": "quest" }, + { "name": "middle-earth" } + ], + "genres": [ + { "name": "fantasy" }, + { "name": "adventure" }, + { "name": "classic" } + ], + "publisher": "Houghton Mifflin", + "pageCount": 398 + }, + "format": "Paperback", + "edition": "50th Anniversary Edition", + "volumeNumber": 1, + "series": "The Lord of the Rings", + "asin": "B007978NPG", + "goodreadsId": "3", + "lccn": "2001025199", + "oclcNumber": "48494995", + "openLibraryId": "OL7603910M", + "libraryThingId": "3203347", + "googleBooksId": "aWZzLPhY4o0C", + "barnesAndNobleId": "1100307790", + "koboId": "the-fellowship-of-the-ring", + "appleBooksId": "id395211", + "isbns": [ + { + { + "value": "0395272238", + "format": "Isbn10" + }, + { + "value": "9780395272237", + "format": "Isbn13" + } + } + ], + "contributors": [ + { + "value": "00000000-0000-0000-0000-000000000000", + } + ], + "ratings": [ + { + "source": "Goodreads", + "value": 4.36, + "maxValue": 5, + "voteCount": 2345678 + }, + { + "source": "Amazon", + "value": 4.7, + "maxValue": 5, + "voteCount": 87654 + } + ] +} +{ + "id": { + "value": "00000000-0000-0000-0000-000000000000" + }, + "metadata": { + "title": "The Lord of the Rings - The Fellowship of the Ring", + "originalTitle": "The Lord of the Rings - The Fellowship of the Ring", + "description": "The greatest fantasy movie ever made", + "releaseInfo": { + "originalReleaseDate": "2001-12-19", + "originalReleaseYear": 2001, + "reReleaseDate": "2024-06-08", + "reReleaseYear": 2024, + "releaseCountry": "us", + "releaseVersion": "Director's Cut" + }, + "language": { + "languageCode": "en", + "languageName": "English", + "nativeName": "English" + }, + "originalLanguage": { + "languageCode": "en", + "languageName": "English", + "nativeName": "English" + }, + "tags": [ + { "name": "epic quest" }, + { "name": "friendship" }, + { "name": "middle-earth" } + ], + "genres": [ + { "name": "fantasy" }, + { "name": "adventure" }, + { "name": "action" } + ], + "publisher": "Allen & Unwin", + "pageCount": 432 + }, + "format": "Hardcover", + "edition": "First Edition", + "volumeNumber": 1, + "series": "The Lord of the Rings", + "isbn": "978-0261103573", + "asin": "B00GO9BZLU", + "goodreadsId": "3", + "lccn": "2001271784", + "oclcNumber": "46516480", + "openLibraryId": "OL7603610M", + "libraryThingId": "3203347", + "googleBooksId": "aWZzLPhY4o0C", + "barnesAndNobleId": "1100307790", + "koboId": "lord-of-the-rings-fellowship-of-the-ring", + "appleBooksId": "id395211", + "contributors": [ + { + "value": "00000000-0000-0000-0000-000000000000", + } + ], + "ratings": [ + { + "source": "Goodreads", + "value": 4.36, + "maxValue": 5, + "voteCount": 2345678 + }, + { + "source": "Amazon", + "value": 4.7, + "maxValue": 5, + "voteCount": 87654 + } + ] +} +``` \ No newline at end of file diff --git a/docs/technical/UbiquitousLanguage.md b/docs/technical/UbiquitousLanguage.md index d0d1df04..aac4b5d2 100644 --- a/docs/technical/UbiquitousLanguage.md +++ b/docs/technical/UbiquitousLanguage.md @@ -121,6 +121,27 @@ - SupplementaryContentLibrary (root: SupplementaryContentLibrary, entities: SubtitleFile, Lyrics, LanguageTrack) - FileManagement (root: File, entities: Stream) +- WrittenContentLibrary + - BookLibrary (root: BookLibrary) + - Entities: Book, BookSeries + - Value Objects: BookMetadata, SeriesInfo + + - ComicLibrary (root: ComicLibrary) + - Entities: ComicBook, ComicSeries, Manga, GraphicNovel + - Value Objects: ComicMetadata, SeriesInfo + + - PeriodicalLibrary (root: PeriodicalLibrary) + - Entities: Magazine, MagazineIssue + - Value Objects: PeriodicalMetadata, IssueInfo + + - AcademicLibrary (root: AcademicLibrary) + - Entities: AcademicPaper + - Value Objects: AcademicMetadata, CitationInfo + + - MiscWrittenContentLibrary (root: MiscWrittenContentLibrary) + - Entities: SheetMusic, Screenplay + - Value Objects: SheetMusicMetadata, ScreenplayMetadata + ## Value Objects - BaseMetadata - VideoMetadata @@ -171,6 +192,36 @@ - FileManagementService - LanguageTrackManager - CrossMediaRelationshipManager +- ContentCurationService +- UserActivityTrackingService +- ContentSynchronizationService + +## Domain Events + +- MediaItemAdded +- MediaItemRemoved +- PlaylistCreated +- PlaylistUpdated +- UserPreferencesChanged +- MetadataUpdated +- FileTranscoded +- StreamStarted +- StreamEnded + +## Bounded Contexts + +- MediaManagement + - Aggregates: VideoLibrary, AudioLibrary, PodcastLibrary, WrittenContentLibrary, PhotoLibrary + - Services: MediaScanner, MetadataFetcher, TranscodingService +- UserExperience + - Aggregates: UserProfile + - Services: RecommendationEngine, ContentCurationService, UserActivityTrackingService +- ContentDelivery + - Aggregates: FileManagement + - Services: StreamingService, ContentSynchronizationService +- MetadataManagement + - Aggregates: SupplementaryContentLibrary + - Services: LyricsMatchingService, ArtworkManagementService ## Repositories - VideoRepository diff --git a/src/Lumina.Domain/Common/Enums/AudioRatingSource.cs b/src/Lumina.Domain/Common/Enums/AudioRatingSource.cs new file mode 100644 index 00000000..2f0ae5df --- /dev/null +++ b/src/Lumina.Domain/Common/Enums/AudioRatingSource.cs @@ -0,0 +1,27 @@ +namespace Lumina.Domain.Common.Enums; + +/// +/// Enumeration for the various sources of audio ratings. +/// +public enum AudioRatingSource +{ + /// + /// Ratings provided by users of the Lumina media library. + /// + User, + + /// + /// Ratings sourced from MusicBrainz, an open music encyclopedia that collects music metadata. + /// + MusicBrainz, + + /// + /// Ratings obtained from Discogs, a database and marketplace for music recordings. + /// + Discogs, + + /// + /// Ratings from Last.fm, a music website that provides music recommendations based on user listening habits. + /// + LastFm, +} \ No newline at end of file diff --git a/src/Lumina.Domain/Common/Enums/BookFormat.cs b/src/Lumina.Domain/Common/Enums/BookFormat.cs new file mode 100644 index 00000000..acb407c6 --- /dev/null +++ b/src/Lumina.Domain/Common/Enums/BookFormat.cs @@ -0,0 +1,67 @@ +namespace Lumina.Domain.Common.Enums; + +/// +/// Enumeration for various book formats. +/// +public enum BookFormat +{ + /// + /// A book bound with rigid protective covers (typically cardboard covered with cloth, heavy paper, or leather). + /// + Hardcover, + + /// + /// A book with a flexible paper cover, typically less durable than a hardcover. + /// + Paperback, + + /// + /// A small, usually non-illustrated, and inexpensive paperback book. + /// + MassMarketPaperback, + + /// + /// A larger, often higher-quality paperback book, typically used for literary fiction and nonfiction. + /// + TradePaperback, + + /// + /// A digital version of a book that can be read on electronic devices. + /// + eBook, + + /// + /// A recorded audio version of a book, either on physical media or as a digital file. + /// + Audiobook, + + /// + /// A book printed with larger text for easier reading, often used by those with visual impairments. + /// + LargePrint, + + /// + /// A sturdy book with thick cardboard pages, typically designed for young children. + /// + BoardBook, + + /// + /// A book bound with a spiral wire or plastic coil, allowing it to lay flat when open. + /// + SpiralBound, + + /// + /// A reinforced binding designed for frequent use, often used in schools and public libraries. + /// + LibraryBinding, + + /// + /// A book bound in leather, often used for luxury or collector's editions. + /// + LeatherBound, + + /// + /// A book with three-dimensional paper engineering, creating pop-up or movable parts. + /// + PopupBook +} \ No newline at end of file diff --git a/src/Lumina.Domain/Common/Enums/BookRatingSource.cs b/src/Lumina.Domain/Common/Enums/BookRatingSource.cs new file mode 100644 index 00000000..e62e4d00 --- /dev/null +++ b/src/Lumina.Domain/Common/Enums/BookRatingSource.cs @@ -0,0 +1,27 @@ +namespace Lumina.Domain.Common.Enums; + +/// +/// Enumeration for the various sources of book ratings. +/// +public enum BookRatingSource +{ + /// + /// Ratings provided by users of the Lumina system. + /// + User, + + /// + /// Ratings sourced from Goodreads, a social network for book readers that provides book recommendations and reviews. + /// + Goodreads, + + /// + /// Ratings obtained from Amazon, an e-commerce platform that includes customer reviews and ratings for books. + /// + Amazon, + + /// + /// Ratings from Google Books, a service that searches the full text of books and magazines that Google has scanned and converted to text. + /// + GoogleBooks, +} \ No newline at end of file diff --git a/src/Lumina.Domain/Common/Enums/IsbnFormat.cs b/src/Lumina.Domain/Common/Enums/IsbnFormat.cs new file mode 100644 index 00000000..dcb017df --- /dev/null +++ b/src/Lumina.Domain/Common/Enums/IsbnFormat.cs @@ -0,0 +1,19 @@ +namespace Lumina.Domain.Common.Enums; + +/// +/// Enumeration for the different ISBN (International Standard Book Number) formats. +/// +public enum IsbnFormat +{ + /// + /// The 10-digit ISBN format used for books published before 2007. + /// Example: 0-306-40615-2 + /// + Isbn10, + + /// + /// The 13-digit ISBN format introduced in 2007, now the standard for all new books. + /// Example: 978-0-306-40615-7 + /// + Isbn13 +} \ No newline at end of file diff --git a/src/Lumina.Domain/Common/Enums/MediaContributorRole.cs b/src/Lumina.Domain/Common/Enums/MediaContributorRole.cs index 87f2e1c6..d17f748d 100644 --- a/src/Lumina.Domain/Common/Enums/MediaContributorRole.cs +++ b/src/Lumina.Domain/Common/Enums/MediaContributorRole.cs @@ -1,12 +1,27 @@ namespace Lumina.Domain.Common.Enums; /// -/// Enumeration for the roles of media contributors. +/// Enumeration for the various roles of media contributors across different types of media. /// public enum MediaContributorRole { + /// + /// A person who portrays a character in a performance, typically in films, television shows, or theater productions. + /// Actor, + + /// + /// The person responsible for overseeing and directing the production of a film, play, television show, or other performing art. + /// Director, + + /// + /// A person who uses their voice to produce musical sounds, typically with a melody and often with lyrics in songs. + /// Singer, + + /// + /// The creator or originator of a written work, such as a book, article, or other literary piece. + /// Author } \ No newline at end of file diff --git a/src/Lumina.Domain/Common/Enums/RatingSource.cs b/src/Lumina.Domain/Common/Enums/RatingSource.cs deleted file mode 100644 index 2464671f..00000000 --- a/src/Lumina.Domain/Common/Enums/RatingSource.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Lumina.Domain.Common.Enums; - -/// -/// Enumeration for the ratings sources. -/// -public enum RatingSource -{ - User, - Imdb, - TheTvDb, - TheMovieDb, - RottenTomatoes, -} \ No newline at end of file diff --git a/src/Lumina.Domain/Common/Enums/VideoRatingSource.cs b/src/Lumina.Domain/Common/Enums/VideoRatingSource.cs new file mode 100644 index 00000000..b8bf17b4 --- /dev/null +++ b/src/Lumina.Domain/Common/Enums/VideoRatingSource.cs @@ -0,0 +1,32 @@ +namespace Lumina.Domain.Common.Enums; + +/// +/// Enumeration for the various sources of video ratings. +/// +public enum VideoRatingSource +{ + /// + /// Ratings provided by users of the Lumina media library. + /// + User, + + /// + /// Ratings sourced from IMDb (Internet Movie Database), an online database of information related to films, TV programs, and video games. + /// + Imdb, + + /// + /// Ratings obtained from TheTVDB, an open database for television shows, including episode information and user ratings. + /// + TheTvDb, + + /// + /// Ratings from The Movie Database (TMDb), a community-built movie and TV database. + /// + TheMovieDb, + + /// + /// Ratings from Rotten Tomatoes, a review-aggregation website for film and television. + /// + RottenTomatoes, +} \ No newline at end of file diff --git a/src/Lumina.Domain/Common/Errors/Errors.WrittenContent.cs b/src/Lumina.Domain/Common/Errors/Errors.WrittenContent.cs new file mode 100644 index 00000000..04b5bf2e --- /dev/null +++ b/src/Lumina.Domain/Common/Errors/Errors.WrittenContent.cs @@ -0,0 +1,21 @@ +#region ========================================================================= USING ===================================================================================== +using ErrorOr; +#endregion + +namespace Lumina.Domain.Common.Errors; + +/// +/// Written content error types. +/// +public static partial class Errors +{ + public static class WrittenContent + { + #region ==================================================================== PROPERTIES ================================================================================= + public static Error IsbnCannotBeEmpty => Error.Validation(nameof(IsbnCannotBeEmpty)); + public static Error InvalidIsbn10Format => Error.Validation(nameof(InvalidIsbn10Format)); + public static Error InvalidIsbn13Format => Error.Validation(nameof(InvalidIsbn13Format)); + public static Error UnknownIsbnFormat => Error.Unexpected(nameof(UnknownIsbnFormat)); + #endregion + } +} \ No newline at end of file diff --git a/src/Lumina.Domain/Common/Models/Core/AggregateRoot.cs b/src/Lumina.Domain/Common/Models/Core/AggregateRoot.cs index e194af37..c4c01d5d 100644 --- a/src/Lumina.Domain/Common/Models/Core/AggregateRoot.cs +++ b/src/Lumina.Domain/Common/Models/Core/AggregateRoot.cs @@ -4,16 +4,20 @@ /// Base class for all domain Aggregate Roots. /// /// The type representing the unique identifier for the Aggregate Root. It should be a non-nullable type. +/// The type of the unique identifier for the Aggregate Root. It should be a non-nullable type. public abstract class AggregateRoot : Entity where TId : notnull, AggregateRootId where TIdType : notnull { #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the unique identifier of the Aggregate Root. + /// public new AggregateRootId Id { get; protected set; } #endregion #region ====================================================================== CTOR ===================================================================================== /// - /// Overload C-tor. + /// Initializes a new instance of the class. /// /// The id of the entity. protected AggregateRoot(TId id) : base(id) @@ -22,6 +26,9 @@ public abstract class AggregateRoot : Entity where TId : notn } #pragma warning disable CS8618 + /// + /// Initializes a new instance of the class. + /// protected AggregateRoot() // only needed during reflection { diff --git a/src/Lumina.Domain/Common/Models/Core/AggregateRootId.cs b/src/Lumina.Domain/Common/Models/Core/AggregateRootId.cs index 9ac7a7e5..64893a2e 100644 --- a/src/Lumina.Domain/Common/Models/Core/AggregateRootId.cs +++ b/src/Lumina.Domain/Common/Models/Core/AggregateRootId.cs @@ -7,6 +7,9 @@ namespace Lumina.Domain.Common.Models.Core; public abstract class AggregateRootId : ValueObject where TId : notnull { #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the unique identifier of the Aggregate Root. + /// public abstract TId Value { get; protected set; } #endregion } \ No newline at end of file diff --git a/src/Lumina.Domain/Common/Models/Core/Entity.cs b/src/Lumina.Domain/Common/Models/Core/Entity.cs index fe748f6a..470a1875 100644 --- a/src/Lumina.Domain/Common/Models/Core/Entity.cs +++ b/src/Lumina.Domain/Common/Models/Core/Entity.cs @@ -7,12 +7,15 @@ public abstract class Entity : IEquatable> where TId : notnull { #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the unique identifier of the entity. + /// public TId Id { get; protected set; } #endregion #region ====================================================================== CTOR ===================================================================================== /// - /// Overload C-tor. + /// Initializes a new instance of the class. /// /// The id of the entity. protected Entity(TId id) @@ -21,6 +24,9 @@ public abstract class Entity : IEquatable> where TId : notnull } #pragma warning disable CS8618 + /// + /// Initializes a new instance of the class. + /// protected Entity() // only needed during reflection { diff --git a/src/Lumina.Domain/Common/Primitives/Optional.cs b/src/Lumina.Domain/Common/Primitives/Optional.cs index 064f4a51..fb89e794 100644 --- a/src/Lumina.Domain/Common/Primitives/Optional.cs +++ b/src/Lumina.Domain/Common/Primitives/Optional.cs @@ -12,7 +12,14 @@ public readonly struct Optional #endregion #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets a value indicating whether this structure has a value. + /// public bool HasValue { get; } + + /// + /// Gets the value represented by this structure. + /// public T Value { get @@ -24,7 +31,7 @@ public readonly struct Optional #region ====================================================================== CTOR ===================================================================================== /// - /// Overload C-tor. + /// Initializes a new instance of the structure. /// /// The value represented by this structure. public Optional(T value) diff --git a/src/Lumina.Domain/Common/ValueObjects/Media/MediaContributor.cs b/src/Lumina.Domain/Common/ValueObjects/Media/MediaContributor.cs deleted file mode 100644 index 5d5731af..00000000 --- a/src/Lumina.Domain/Common/ValueObjects/Media/MediaContributor.cs +++ /dev/null @@ -1,54 +0,0 @@ -#region ========================================================================= USING ===================================================================================== -using ErrorOr; -using Lumina.Domain.Common.Enums; -using Lumina.Domain.Common.Models.Core; -using Lumina.Domain.Common.Primitives; -#endregion - -namespace Lumina.Domain.Common.ValueObjects.Media; - -/// -/// Value Object for a contributor of a media element. -/// -public sealed class MediaContributor : ValueObject -{ - #region ==================================================================== PROPERTIES ================================================================================= - public PersonId PersonId { get; } - public Optional Role { get; } - #endregion - - #region ====================================================================== CTOR ===================================================================================== - /// - /// Overload C-tor. - /// - /// The id of the person represented by this object. - /// The role of the person represented by this object. - private MediaContributor(PersonId personId, Optional role) - { - Role = role; - PersonId = personId; - } - #endregion - - #region ===================================================================== METHODS =================================================================================== - /// - /// Creates a new instance of . - /// - /// The id of the person represented by this object. - /// The role of the person represented by this object. - /// - /// An containing either a successfully created or an error message. - /// - public static ErrorOr Create(PersonId personId, Optional role) - { - return new MediaContributor(personId, role); - } - - /// - public override IEnumerable GetEqualityComponents() - { - yield return PersonId; - yield return Role; - } - #endregion -} \ No newline at end of file diff --git a/src/Lumina.Domain/Common/ValueObjects/Metadata/BaseMetadata.cs b/src/Lumina.Domain/Common/ValueObjects/Metadata/BaseMetadata.cs index 004a49b6..da747d33 100644 --- a/src/Lumina.Domain/Common/ValueObjects/Metadata/BaseMetadata.cs +++ b/src/Lumina.Domain/Common/ValueObjects/Metadata/BaseMetadata.cs @@ -1,4 +1,5 @@ #region ========================================================================= USING ===================================================================================== +using System.Diagnostics; using Lumina.Domain.Common.Models.Core; using Lumina.Domain.Common.Primitives; #endregion @@ -8,53 +9,65 @@ namespace Lumina.Domain.Common.ValueObjects.Metadata; /// /// Base template for all metadata-related value objects. /// +[DebuggerDisplay("{Title}")] public abstract class BaseMetadata : ValueObject { + #region ================================================================== FIELD MEMBERS ================================================================================ + private readonly List _tags; + private readonly List _genres; + #endregion + #region ==================================================================== PROPERTIES ================================================================================= /// /// Gets the title of the media item. /// - public string Title { get; } + public string Title { get; private set;} /// /// Gets the original title of the media item. /// - public Optional OriginalTitle { get; } + public Optional OriginalTitle { get; private set; } /// /// Gets the optional description of the media item. /// - public Optional Description { get; } + public Optional Description { get; private set; } /// /// Gets the release information of the media item. /// - public ReleaseInfo ReleaseInfo { get; } + public ReleaseInfo ReleaseInfo { get; private set; } - /// - /// Gets the list of tags associated with the media item. - /// - public IReadOnlyList Tags { get; } - - /// - /// Gets the list of genres associated with the media item. - /// - public IReadOnlyList Genres { get; } - /// /// Gets the optional language of the media item. /// - public Optional Language { get; } + public Optional Language { get; private set; } /// /// Gets the optional original language of the media item. /// - public Optional OriginalLanguage { get; } + public Optional OriginalLanguage { get; private set; } + + /// + /// Gets the list of tags associated with the media item. + /// + public IReadOnlyCollection Tags + { + get { return _tags.AsReadOnly(); } + } + + /// + /// Gets the list of genres associated with the media item. + /// + public IReadOnlyCollection Genres + { + get { return _genres.AsReadOnly(); } + } #endregion #region ====================================================================== CTOR ===================================================================================== /// - /// Overload C-tor. + /// Initializes a new instance of the class. /// /// The title of the element to which this metadata object belongs to. /// The optional original title of the element to which this metadata object belongs to. @@ -65,15 +78,22 @@ public abstract class BaseMetadata : ValueObject /// The optional language of the element to which this metadata object belongs to. /// The optional original language of the element to which this metadata object belongs to. /// Thrown when the value is - protected BaseMetadata(string title, Optional originalTitle, ReleaseInfo releaseInfo, Optional description, - IEnumerable? genres, IEnumerable? tags, Optional language, Optional originalLanguage) + protected BaseMetadata( + string title, + Optional originalTitle, + ReleaseInfo releaseInfo, + Optional description, + List genres, + List tags, + Optional language, + Optional originalLanguage) { Title = title ?? throw new ArgumentNullException(nameof(title)); OriginalTitle = originalTitle; ReleaseInfo = releaseInfo; Description = description; - Genres = genres?.ToList().AsReadOnly() ?? new List().AsReadOnly(); - Tags = tags?.ToList().AsReadOnly() ?? new List().AsReadOnly(); + _genres = genres; + _tags = tags; Language = language; OriginalLanguage = originalLanguage; } @@ -87,9 +107,9 @@ public abstract class BaseMetadata : ValueObject yield return OriginalTitle; yield return ReleaseInfo; yield return Description; - foreach (var genre in Genres) + foreach (var genre in _genres) yield return genre; - foreach (var tag in Tags) + foreach (var tag in _tags) yield return tag; yield return Language; yield return OriginalLanguage; diff --git a/src/Lumina.Domain/Common/ValueObjects/Metadata/Genre.cs b/src/Lumina.Domain/Common/ValueObjects/Metadata/Genre.cs index 72d364e0..d2d6fc70 100644 --- a/src/Lumina.Domain/Common/ValueObjects/Metadata/Genre.cs +++ b/src/Lumina.Domain/Common/ValueObjects/Metadata/Genre.cs @@ -21,7 +21,7 @@ public class Genre : ValueObject #region ====================================================================== CTOR ===================================================================================== /// - /// Overload C-tor. + /// Initializes a new instance of the class. /// /// The value representing this object. private Genre(string name) @@ -32,7 +32,7 @@ public class Genre : ValueObject #region ===================================================================== METHODS =================================================================================== /// - /// Creates a new instance of . + /// Creates a new instance of the class. /// /// The value of the genre. /// diff --git a/src/Lumina.Domain/Common/ValueObjects/Metadata/LanguageInfo.cs b/src/Lumina.Domain/Common/ValueObjects/Metadata/LanguageInfo.cs index a51ac8e4..3647621e 100644 --- a/src/Lumina.Domain/Common/ValueObjects/Metadata/LanguageInfo.cs +++ b/src/Lumina.Domain/Common/ValueObjects/Metadata/LanguageInfo.cs @@ -33,7 +33,7 @@ public class LanguageInfo : ValueObject #region ====================================================================== CTOR ===================================================================================== /// - /// Overload C-tor. + /// Initializes a new instance of the class. /// /// The ISO 639-1 two-letter language code. /// The full name of the language in English. @@ -50,7 +50,7 @@ public class LanguageInfo : ValueObject #region ===================================================================== METHODS =================================================================================== /// - /// Creates a new instance of . + /// Creates a new instance of the class. /// /// The ISO 639-1 two-letter language code. /// The full name of the language in English. diff --git a/src/Lumina.Domain/Common/ValueObjects/Metadata/Rating.cs b/src/Lumina.Domain/Common/ValueObjects/Metadata/Rating.cs index 9b760305..befe204e 100644 --- a/src/Lumina.Domain/Common/ValueObjects/Metadata/Rating.cs +++ b/src/Lumina.Domain/Common/ValueObjects/Metadata/Rating.cs @@ -28,7 +28,7 @@ public class Rating : ValueObject /// /// Gets the optional source of the rating (e.g., "IMDB", "Rotten Tomatoes"). /// - public Optional Source { get; } + public Optional Source { get; } /// /// Gets the optional number of votes or reviews this rating is based on. @@ -38,13 +38,13 @@ public class Rating : ValueObject #region ====================================================================== CTOR ===================================================================================== /// - /// Overload C-tor. + /// Initializes a new instance of the class. /// /// The numeric value of the rating. /// The maximum possible rating value. /// The optional source of the rating. /// The optional number of votes or reviews. - private Rating(decimal value, decimal maxValue, Optional source = default, Optional voteCount = default) + private Rating(decimal value, decimal maxValue, Optional source, Optional voteCount) { Value = value; MaxValue = maxValue; @@ -55,7 +55,7 @@ public class Rating : ValueObject #region ===================================================================== METHODS =================================================================================== /// - /// Creates a new instance of . + /// Creates a new instance of the class. /// /// The numeric value of the rating. /// The maximum possible rating value. @@ -64,7 +64,7 @@ public class Rating : ValueObject /// /// An containing either a successfully created or an error message. /// - public static ErrorOr Create(decimal value, decimal maxValue, Optional source = default, Optional voteCount = default) + public static ErrorOr Create(decimal value, decimal maxValue, Optional source, Optional voteCount) { if (maxValue < 0 || value < 0) return Errors.Errors.Metadata.RatingMustBePositive; diff --git a/src/Lumina.Domain/Common/ValueObjects/Metadata/ReleaseInfo.cs b/src/Lumina.Domain/Common/ValueObjects/Metadata/ReleaseInfo.cs index 7024c9f7..6d799931 100644 --- a/src/Lumina.Domain/Common/ValueObjects/Metadata/ReleaseInfo.cs +++ b/src/Lumina.Domain/Common/ValueObjects/Metadata/ReleaseInfo.cs @@ -48,7 +48,7 @@ public class ReleaseInfo : ValueObject #region ====================================================================== CTOR ===================================================================================== /// - /// Overload C-tor. + /// Initializes a new instance of the class. /// /// The optional original release date of the media item. /// The optional original release year of the media item. @@ -56,8 +56,13 @@ public class ReleaseInfo : ValueObject /// The optional re-release year of the media item. /// The optional country or region of release. /// The optional release version or edition. - private ReleaseInfo(Optional originalReleaseDate, Optional originalReleaseYear, - Optional reReleaseDate, Optional reReleaseYear, Optional releaseCountry, Optional releaseVersion) + private ReleaseInfo( + Optional originalReleaseDate, + Optional originalReleaseYear, + Optional reReleaseDate, + Optional reReleaseYear, + Optional releaseCountry, + Optional releaseVersion) { OriginalReleaseDate = originalReleaseDate; OriginalReleaseYear = originalReleaseYear; @@ -70,7 +75,7 @@ public class ReleaseInfo : ValueObject #region ===================================================================== METHODS =================================================================================== /// - /// Creates a new instance of . + /// Creates a new instance of the class. /// /// The optional original release date of the media item. /// The optional original release year of the media item. @@ -81,8 +86,13 @@ public class ReleaseInfo : ValueObject /// /// An containing either a successfully created or an error message. /// - public static ErrorOr Create(Optional originalReleaseDate, Optional originalReleaseYear, - Optional reReleaseDate, Optional reReleaseYear, Optional releaseCountry, Optional releaseVersion) + public static ErrorOr Create( + Optional originalReleaseDate, + Optional originalReleaseYear, + Optional reReleaseDate, + Optional reReleaseYear, + Optional releaseCountry, + Optional releaseVersion) { if (originalReleaseDate.HasValue && originalReleaseYear.HasValue && originalReleaseDate.Value.Year != originalReleaseYear.Value) return Errors.Errors.Metadata.OriginalReleaseDateAndYearMustMatch; diff --git a/src/Lumina.Domain/Common/ValueObjects/Metadata/Tag.cs b/src/Lumina.Domain/Common/ValueObjects/Metadata/Tag.cs index 1614ca87..0fb0c321 100644 --- a/src/Lumina.Domain/Common/ValueObjects/Metadata/Tag.cs +++ b/src/Lumina.Domain/Common/ValueObjects/Metadata/Tag.cs @@ -21,7 +21,7 @@ public class Tag : ValueObject #region ====================================================================== CTOR ===================================================================================== /// - /// Overload C-tor. + /// Initializes a new instance of the class. /// /// The value representing this object. private Tag(string name) @@ -32,7 +32,7 @@ public class Tag : ValueObject #region ===================================================================== METHODS =================================================================================== /// - /// Creates a new instance of . + /// Creates a new instance of the class. /// /// The value of the tag. /// diff --git a/src/Lumina.Domain/Core/Aggregates/AudioLibrary/AudioLibraryAggregate/ValueObjects/AudioMetadata.cs b/src/Lumina.Domain/Core/Aggregates/AudioLibrary/AudioLibraryAggregate/ValueObjects/AudioMetadata.cs new file mode 100644 index 00000000..8ff8cf52 --- /dev/null +++ b/src/Lumina.Domain/Core/Aggregates/AudioLibrary/AudioLibraryAggregate/ValueObjects/AudioMetadata.cs @@ -0,0 +1,158 @@ +#region ========================================================================= USING ===================================================================================== +using ErrorOr; +using Lumina.Domain.Common.Primitives; +using Lumina.Domain.Common.ValueObjects.Metadata; +using System.Diagnostics; +#endregion + +namespace Lumina.Domain.Core.Aggregates.AudioLibrary.AudioLibraryAggregate.ValueObjects; + +/// +/// Value Object for the audio metadata of a media element. +/// +[DebuggerDisplay("{Title}")] +public class AudioMetadata : BaseMetadata +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the duration of the video in seconds. + /// + public int DurationInSeconds { get; } + + /// + /// Gets the sample rate of the audio in Hz. + /// + public int SampleRate { get; } + + /// + /// Gets the number of audio channels. + /// + public int Channels { get; } + + /// + /// Gets the bit depth of the audio. + /// + public Optional BitDepth { get; } + + /// + /// Gets the audio codec used. + /// + public Optional AudioCodec { get; } + + /// + /// Gets the bitrate of the audio in kbps. + /// + public Optional Bitrate { get; } + #endregion + + #region ====================================================================== CTOR ===================================================================================== + /// + /// Initializes a new instance of the class. + /// + /// The title of the audio. + /// The optional original title of the video. + /// The duration of the audio, in seconds. + /// The sample rate of the audio, in Hz. + /// The number of audio channels. + /// The release information of the audio. + /// The description of the audio. + /// The language of the audio. + /// The optional original language of the video. + /// The bit depth of the audio. + /// The audio codec used. + /// The genres of the audio. + /// The tags associated with the audio. + public AudioMetadata( + string title, + Optional originalTitle, + int durationInSeconds, + int sampleRate, + int channels, + ReleaseInfo release, + Optional description, + List genres, + List tags, + Optional language, + Optional originalLanguage, + Optional bitDepth, + Optional audioCodec, + Optional bitrate) + : base(title, originalTitle, release, description, genres, tags, language, originalLanguage) + { + DurationInSeconds = durationInSeconds; + SampleRate = sampleRate; + Channels = channels; + BitDepth = bitDepth; + AudioCodec = audioCodec; + Bitrate = bitrate; + } + #endregion + + #region ===================================================================== METHODS =================================================================================== + /// + /// Creates a new instance of the class. + /// + /// The title of the audio. + /// The optional original title of the video. + /// The duration of the audio, in seconds. + /// The sample rate of the audio, in Hz. + /// The number of audio channels. + /// The release information of the audio. + /// The description of the audio. + /// The language of the audio. + /// The optional original language of the video. + /// The bit depth of the audio. + /// The audio codec used. + /// The genres of the audio. + /// The tags associated with the audio. + /// + /// An containing either a successfully created or an error message. + /// + public static ErrorOr Create( + string title, + Optional originalTitle, + int durationInSeconds, + int sampleRate, + int channels, + ReleaseInfo release, + Optional + description, + List genres, + List tags, + Optional language, + Optional originalLanguage, + Optional bitDepth, + Optional audioCodec, + Optional bitrate) + { + return new AudioMetadata( + title, + originalTitle, + durationInSeconds, + sampleRate, + channels, + release, + description, + genres, + tags, + language, + originalLanguage, + bitDepth, + audioCodec, + bitrate); + } + + /// + public override IEnumerable GetEqualityComponents() + { + foreach (var component in base.GetEqualityComponents()) + yield return component; + yield return DurationInSeconds; + yield return SampleRate; + yield return Channels; + yield return BitDepth; + yield return AudioCodec; + yield return Bitrate; + } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Domain/FileManagementAggregate/ValueObjects/FileInfo.cs b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/ValueObjects/FileInfo.cs similarity index 93% rename from src/Lumina.Domain/FileManagementAggregate/ValueObjects/FileInfo.cs rename to src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/ValueObjects/FileInfo.cs index ee557566..03486b09 100644 --- a/src/Lumina.Domain/FileManagementAggregate/ValueObjects/FileInfo.cs +++ b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/ValueObjects/FileInfo.cs @@ -5,7 +5,7 @@ using Lumina.Domain.Common.Primitives; using Lumina.Domain.Common.Errors; #endregion -namespace Lumina.Domain.FileManagementAggregate.ValueObjects; +namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects; /// /// Value Object for the information of a file. @@ -41,7 +41,7 @@ public class FileInfo : ValueObject #region ====================================================================== CTOR ===================================================================================== /// - /// Overload C-tor. + /// Initializes a new instance of the class. /// /// The full path of the file. /// The file extension. @@ -60,7 +60,7 @@ public class FileInfo : ValueObject #region ===================================================================== METHODS =================================================================================== /// - /// Creates a new instance of . + /// Creates a new instance of the class. /// /// The full path of the file. /// The file extension. diff --git a/src/Lumina.Domain/FileManagementAggregate/ValueObjects/StreamInfo.cs b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/ValueObjects/StreamInfo.cs similarity index 85% rename from src/Lumina.Domain/FileManagementAggregate/ValueObjects/StreamInfo.cs rename to src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/ValueObjects/StreamInfo.cs index aa166220..428bb218 100644 --- a/src/Lumina.Domain/FileManagementAggregate/ValueObjects/StreamInfo.cs +++ b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/ValueObjects/StreamInfo.cs @@ -5,7 +5,7 @@ using Lumina.Domain.Common.Primitives; using Lumina.Domain.Common.Errors; #endregion -namespace Lumina.Domain.FileManagementAggregate.ValueObjects; +namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects; /// /// Value Object for the information about a media stream. @@ -56,7 +56,7 @@ public class StreamInfo : ValueObject #region ====================================================================== CTOR ===================================================================================== /// - /// Overload C-tor. + /// Initializes a new instance of the class. /// /// The unique identifier for the stream. /// The MIME type of the stream content. @@ -66,8 +66,15 @@ public class StreamInfo : ValueObject /// The frame rate of the stream (for video). /// The sample rate of the stream (for audio). /// The number of channels (for audio). - private StreamInfo(string streamId, string mimeType, int bitrate, string codec, - Optional resolution = default, Optional frameRate = default, Optional sampleRate = default, Optional channels = default) + private StreamInfo( + string streamId, + string mimeType, + int bitrate, + string codec, + Optional resolution, + Optional frameRate, + Optional sampleRate, + Optional channels) { StreamId = streamId; MimeType = mimeType; @@ -82,7 +89,7 @@ public class StreamInfo : ValueObject #region ===================================================================== METHODS =================================================================================== /// - /// Creates a new instance of . + /// Creates a new instance of the class. /// /// The unique identifier for the stream. /// The MIME type of the stream content. @@ -95,8 +102,15 @@ public class StreamInfo : ValueObject /// /// An containing either a successfully created or an error message. /// - public static ErrorOr Create(string streamId, string mimeType, int bitrate, string codec, - Optional resolution = default, Optional frameRate = default, Optional sampleRate = default, Optional channels = default) + public static ErrorOr Create( + string streamId, + string mimeType, + int bitrate, + string codec, + Optional resolution, + Optional frameRate, + Optional sampleRate, + Optional channels) { if (streamId is null) return Errors.FileManagement.StreamIdCannotBeEmpty; diff --git a/src/Lumina.Domain/Core/Aggregates/MediaContributor/MediaContributorAggregate/MediaContributor.cs b/src/Lumina.Domain/Core/Aggregates/MediaContributor/MediaContributorAggregate/MediaContributor.cs new file mode 100644 index 00000000..7ebf8785 --- /dev/null +++ b/src/Lumina.Domain/Core/Aggregates/MediaContributor/MediaContributorAggregate/MediaContributor.cs @@ -0,0 +1,100 @@ +#region ========================================================================= USING ===================================================================================== +using System.Diagnostics; +using ErrorOr; +using Lumina.Domain.Common.Enums; +using Lumina.Domain.Common.Models.Core; +using Lumina.Domain.Common.Primitives; +using Lumina.Domain.Core.Aggregates.MediaContributor.MediaContributorAggregate.ValueObjects; +#endregion + + +namespace Lumina.Domain.Core.Aggregates.MediaContributor.MediaContributorAggregate; + +/// +/// Aggregate Root for a media contributor. +/// +[DebuggerDisplay("{Id}: {Name}")] +public class MediaContributor : AggregateRoot +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the name of the contributor. + /// + public MediaContributorName Name { get; private set; } + + /// + /// Gets the role of the contributor. + /// + public MediaContributorRole Role { get; private set; } + + /// + /// Gets the biography of the contributor. + /// + public Optional Biography { get; private set; } + + /// + /// Gets the date of birth of the contributor. + /// + public Optional DateOfBirth { get; private set; } + + /// + /// Gets the date of death of the contributor. + /// + public Optional DateOfDeath { get; private set; } + #endregion + + #region ====================================================================== CTOR ===================================================================================== + /// + /// Initializes a new instance of the class. + /// + /// The unique identifier of the contributor. + /// The name of the contributor. + /// The role of the contributor. + /// The optional date of birth of the contributor. + /// The optional date of death of the contributor. + private MediaContributor( + MediaContributorId id, + MediaContributorName name, + MediaContributorRole role, + Optional dateOfBirth, + Optional dateOfDeath) + { + Id = id; + Name = name; + Role = role; + DateOfBirth = dateOfBirth; + DateOfDeath = dateOfDeath; + } + #endregion + + #region ===================================================================== METHODS =================================================================================== + /// + /// Creates a new instance of the class. + /// + /// The unique identifier of the contributor. + /// The name of the contributor. + /// The created instance. + public static ErrorOr Create(MediaContributorName name) + { + // TODO: enforce invariants + throw new NotImplementedException(); + //return new MediaContributor(id, name); + } + + /// + /// Creates a new instance of the class, from a pre-existing . + /// + /// The unique identifier of the contributor. + /// The name of the contributor. + /// The created instance. + public static ErrorOr Create( + MediaContributorId id, + MediaContributorName name, + MediaContributorRole role, + Optional dateOfBirth, + Optional dateOfDeath) + { + return new MediaContributor(id, name, role, dateOfBirth, dateOfDeath); + } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Domain/Core/Aggregates/MediaContributor/MediaContributorAggregate/ValueObjects/ContributorName.cs b/src/Lumina.Domain/Core/Aggregates/MediaContributor/MediaContributorAggregate/ValueObjects/ContributorName.cs new file mode 100644 index 00000000..f58b98bb --- /dev/null +++ b/src/Lumina.Domain/Core/Aggregates/MediaContributor/MediaContributorAggregate/ValueObjects/ContributorName.cs @@ -0,0 +1,61 @@ +#region ========================================================================= USING ===================================================================================== +using System.Diagnostics; +using ErrorOr; +using Lumina.Domain.Common.Models.Core; +using Lumina.Domain.Common.Primitives; +#endregion + +namespace Lumina.Domain.Core.Aggregates.MediaContributor.MediaContributorAggregate.ValueObjects; + +/// +/// Value Object for the name of a person. +/// +[DebuggerDisplay("{DisplayName}")] +public sealed class MediaContributorName : ValueObject +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the name by which the contributor is popularly known. + /// + public string DisplayName { get; private set; } + + /// + /// Gets the legal name of the contributor. + /// + public Optional LegalName { get; private set; } + #endregion + + #region ====================================================================== CTOR ===================================================================================== + /// + /// Initializes a new instance of the class. + /// + /// The name by which the contributor is popularly known. + /// The legal name of the contributor. + private MediaContributorName(string displayName, Optional legalName) + { + DisplayName = displayName; + LegalName = legalName; + } + #endregion + + #region ===================================================================== METHODS =================================================================================== + /// + /// Creates a new instance of the class. + /// + /// The name by which the contributor is popularly known. + /// The legal name of the contributor. + /// The created instance. + public static ErrorOr Create(string displayName, Optional legalName) + { + // TODO: enforce invariants + return new MediaContributorName(displayName, legalName); + } + + /// + public override IEnumerable GetEqualityComponents() + { + yield return DisplayName; + yield return LegalName; + } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Domain/Core/Aggregates/MediaContributor/MediaContributorAggregate/ValueObjects/MediaContributorId.cs b/src/Lumina.Domain/Core/Aggregates/MediaContributor/MediaContributorAggregate/ValueObjects/MediaContributorId.cs new file mode 100644 index 00000000..76021cc3 --- /dev/null +++ b/src/Lumina.Domain/Core/Aggregates/MediaContributor/MediaContributorAggregate/ValueObjects/MediaContributorId.cs @@ -0,0 +1,55 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Domain.Common.Models.Core; +#endregion + +namespace Lumina.Domain.Core.Aggregates.MediaContributor.MediaContributorAggregate.ValueObjects; + +/// +/// Value Object for the Id of a media contributor. +/// +public sealed class MediaContributorId : AggregateRootId +{ + #region ==================================================================== PROPERTIES ================================================================================= + public override Guid Value { get; protected set; } + #endregion + + #region ====================================================================== CTOR ===================================================================================== + /// + /// Initializes a new instance of the class. + /// + /// The value representing this object. + private MediaContributorId(Guid value) + { + Value = value; + } + #endregion + + #region ===================================================================== METHODS =================================================================================== + /// + /// Creates a new instance of the class. + /// + /// The created instance. + public static MediaContributorId CreateUnique() + { + // TODO: enforce invariants + return new MediaContributorId(Guid.NewGuid()); + } + + /// + /// Creates a new instance of the class, from a pre-existing . + /// + /// The value used to create the instance. + /// The created instance. + public static MediaContributorId Create(Guid value) + { + // TODO: enforce invariants + return new MediaContributorId(value); + } + + /// + public override IEnumerable GetEqualityComponents() + { + yield return Value; + } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Domain/Core/Aggregates/VideoLibrary/MovieLibraryAggregate/Movie.cs b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/MovieLibraryAggregate/Movie.cs new file mode 100644 index 00000000..f68f4cec --- /dev/null +++ b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/MovieLibraryAggregate/Movie.cs @@ -0,0 +1,101 @@ +#region ========================================================================= USING ===================================================================================== +using System.Diagnostics; +using ErrorOr; +using Lumina.Domain.Common.Models.Core; +using Lumina.Domain.Common.ValueObjects.Metadata; +using Lumina.Domain.Core.Aggregates.MediaContributor.MediaContributorAggregate.ValueObjects; +using Lumina.Domain.Core.Aggregates.VideoLibrary.MovieLibraryAggregate.ValueObjects; +#endregion + +namespace Lumina.Domain.Core.Aggregates.VideoLibrary.MovieLibraryAggregate; + +/// +/// Entity for a movie. +/// +[DebuggerDisplay("{Id}: {Title}")] +public sealed class Movie : Entity +{ + #region ================================================================== FIELD MEMBERS ================================================================================ + private readonly List _contributors; + private readonly List _ratings; + #endregion + + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the video metadata of the movie. + /// + public VideoMetadata Metadata { get; private set; } + + /// + /// Gets the list of ratings for this movie. + /// + public IReadOnlyCollection Ratings + { + get { return _ratings.AsReadOnly(); } + } + + /// + /// Gets the list of media contributors (actors, directors, etc) starring in this movie. + /// + public IReadOnlyCollection Contributors + { + get { return _contributors.AsReadOnly(); } + } + #endregion + + #region ====================================================================== CTOR ===================================================================================== + /// + /// Initializes a new instance of the class. + /// + /// The unique identifier of the movie. + /// The metadata of the movie. + /// The list of the contributors of the movie. + /// The list of ratings for the movie. + public Movie(MovieId id, VideoMetadata metadata, List contributors, List ratings) : base(id) + { + Id = id; + Metadata = metadata; + _contributors = contributors; + _ratings = ratings; + } + +#pragma warning disable CS8618 + /// + /// Initializes a new instance of the class. + /// + private Movie() // only needed during reflection + { + + } +#pragma warning restore CS8618 + #endregion + + #region ===================================================================== METHODS =================================================================================== + /// + /// Creates a new instance of the class. + /// + /// The metadata of the movie. + /// The list of media contributors of the movie. + /// The list of ratings for the movie. + /// The created . + public static ErrorOr Create(VideoMetadata metadata, List contributors, List ratings) + { + // TODO: enforce invariants + return new Movie(MovieId.CreateUnique(), metadata, contributors, ratings); + } + + /// + /// Creates a new instance of the class, with a pre-existing . + /// + /// The object representing the id of the movie. + /// The metadata of the movie. + /// The list of media contributors of the movie. + /// The list of ratings for the movie. + /// The created . + public static ErrorOr Create(MovieId id, VideoMetadata metadata, List contributors, List ratings) + { + // TODO: enforce invariants + return new Movie(id, metadata, contributors, ratings); + } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Domain/Core/Aggregates/VideoLibrary/MovieLibraryAggregate/Services/IMovieLibraryService.cs b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/MovieLibraryAggregate/Services/IMovieLibraryService.cs new file mode 100644 index 00000000..5d69dd83 --- /dev/null +++ b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/MovieLibraryAggregate/Services/IMovieLibraryService.cs @@ -0,0 +1,14 @@ +namespace Lumina.Domain.Core.Aggregates.VideoLibrary.MovieLibraryAggregate.Services; + +/// +/// Service for managing movie libraries. +/// +public interface IMovieLibraryService +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the collection of movies in the library. + /// + public ICollection Movies { get; } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Domain/Core/Aggregates/VideoLibrary/MovieLibraryAggregate/Services/MovieLibraryService.cs b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/MovieLibraryAggregate/Services/MovieLibraryService.cs new file mode 100644 index 00000000..31864f70 --- /dev/null +++ b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/MovieLibraryAggregate/Services/MovieLibraryService.cs @@ -0,0 +1,14 @@ +namespace Lumina.Domain.Core.Aggregates.VideoLibrary.MovieLibraryAggregate.Services; + +public sealed class MovieLibraryService : IMovieLibraryService +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the collection of movies in the library. + /// + public ICollection Movies + { + get { throw new NotImplementedException(); } + } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Domain/Core/Aggregates/VideoLibrary/MovieLibraryAggregate/ValueObjects/MovieId.cs b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/MovieLibraryAggregate/ValueObjects/MovieId.cs new file mode 100644 index 00000000..dd166fbb --- /dev/null +++ b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/MovieLibraryAggregate/ValueObjects/MovieId.cs @@ -0,0 +1,55 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Domain.Common.Models.Core; +#endregion + +namespace Lumina.Domain.Core.Aggregates.VideoLibrary.MovieLibraryAggregate.ValueObjects; + +/// +/// Value Object for the Id of a movie. +/// +public sealed class MovieId : ValueObject +{ + #region ==================================================================== PROPERTIES ================================================================================= + public Guid Value { get; } + #endregion + + #region ====================================================================== CTOR ===================================================================================== + /// + /// Initializes a new instance of the class. + /// + /// The value representing this object. + private MovieId(Guid value) + { + Value = value; + } + #endregion + + #region ===================================================================== METHODS =================================================================================== + /// + /// Creates a new instance of the class. + /// + /// The created instance. + public static MovieId CreateUnique() + { + // TODO: enforce invariants + return new MovieId(Guid.NewGuid()); + } + + /// + /// Creates a new instance of the class, from a pre-existing . + /// + /// The value used to create the instance. + /// The created instance. + public static MovieId Create(Guid value) + { + // TODO: enforce invariants + return new MovieId(value); + } + + /// + public override IEnumerable GetEqualityComponents() + { + yield return Value; + } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Domain/Common/ValueObjects/Metadata/VideoMetadata.cs b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/MovieLibraryAggregate/ValueObjects/VideoMetadata.cs similarity index 72% rename from src/Lumina.Domain/Common/ValueObjects/Metadata/VideoMetadata.cs rename to src/Lumina.Domain/Core/Aggregates/VideoLibrary/MovieLibraryAggregate/ValueObjects/VideoMetadata.cs index ff7df349..ff8eba44 100644 --- a/src/Lumina.Domain/Common/ValueObjects/Metadata/VideoMetadata.cs +++ b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/MovieLibraryAggregate/ValueObjects/VideoMetadata.cs @@ -1,16 +1,16 @@ #region ========================================================================= USING ===================================================================================== using ErrorOr; using Lumina.Domain.Common.Primitives; -using Lumina.Domain.Common.ValueObjects.Media; +using Lumina.Domain.Common.ValueObjects.Metadata; using System.Diagnostics; #endregion -namespace Lumina.Domain.Common.ValueObjects.Metadata; +namespace Lumina.Domain.Core.Aggregates.VideoLibrary.MovieLibraryAggregate.ValueObjects; /// -/// Value Object for the rating of a media element. +/// Value Object for the video metadata of a media element. /// -[DebuggerDisplay("{Value}/{MaxValue}")] +[DebuggerDisplay("{Title}")] public class VideoMetadata : BaseMetadata { #region ==================================================================== PROPERTIES ================================================================================= @@ -22,7 +22,7 @@ public class VideoMetadata : BaseMetadata /// /// Gets the resolution of the video. /// - public string Resolution { get; } + public string Resolution { get; } // TODO: should be implemented as a value object with width, height, aspet ratio, etc. /// /// Gets the frame rate of the video. @@ -38,20 +38,15 @@ public class VideoMetadata : BaseMetadata /// Gets the audio codec used. /// public Optional AudioCodec { get; } - - /// - /// Gets the list of actors starring in this video. - /// - public IReadOnlyList Contributors { get; } #endregion #region ====================================================================== CTOR ===================================================================================== /// - /// Overload C-tor. + /// Initializes a new instance of the class. /// /// The title of the video. /// The optional original title of the video. - /// The duration of the video in seconds. + /// The duration of the video, in seconds. /// The resolution of the video. /// The release information of the video. /// The optional description of the video. @@ -62,10 +57,20 @@ public class VideoMetadata : BaseMetadata /// The optional audio codec used. /// The genres of the video. /// The tags associated with the video. - /// The list of contributors for this video. - private VideoMetadata(string title, Optional originalTitle, int durationInSeconds, string resolution, ReleaseInfo release, Optional description, - Optional language, Optional originalLanguage, Optional frameRate, Optional videoCodec, Optional audioCodec, - IEnumerable? genres = null, IEnumerable? tags = null, IEnumerable? contributors = null) + private VideoMetadata( + string title, + Optional originalTitle, + int durationInSeconds, + string resolution, + ReleaseInfo release, + Optional description, + Optional language, + Optional originalLanguage, + Optional frameRate, + Optional videoCodec, + Optional audioCodec, + List genres, + List tags) : base(title, originalTitle, release, description, genres, tags, language, originalLanguage) { DurationInSeconds = durationInSeconds; @@ -73,13 +78,12 @@ public class VideoMetadata : BaseMetadata FrameRate = frameRate; VideoCodec = videoCodec; AudioCodec = audioCodec; - Contributors = contributors?.ToList().AsReadOnly() ?? new List().AsReadOnly(); } #endregion #region ===================================================================== METHODS =================================================================================== /// - /// Creates a new instance of . + /// Creates a new instance of the class. /// /// The title of the video. /// The optional original title of the video. @@ -98,12 +102,23 @@ public class VideoMetadata : BaseMetadata /// /// An containing either a successfully created or an error message. /// - public static ErrorOr Create(string title, Optional originalTitle, int durationInSeconds, string resolution, ReleaseInfo release, Optional description, - Optional language, Optional originalLanguage, Optional frameRate, Optional videoCodec, Optional audioCodec, - IEnumerable? genres = null, IEnumerable? tags = null, IEnumerable? contributors = null) + public static ErrorOr Create( + string title, + Optional originalTitle, + int durationInSeconds, + string resolution, + ReleaseInfo release, + Optional description, + Optional language, + Optional originalLanguage, + Optional frameRate, + Optional videoCodec, + Optional audioCodec, + List genres, + List tags) { return new VideoMetadata(title, originalTitle, durationInSeconds, resolution, release, description, - language, originalLanguage, frameRate, videoCodec, audioCodec, genres, tags, contributors); + language, originalLanguage, frameRate, videoCodec, audioCodec, genres, tags); } /// @@ -116,8 +131,6 @@ public class VideoMetadata : BaseMetadata yield return FrameRate; yield return VideoCodec; yield return AudioCodec; - foreach (var contributor in Contributors) - yield return contributor; } #endregion } \ No newline at end of file diff --git a/src/Lumina.Domain/Core/Aggregates/VideoLibrary/Services/IVideoLibraryService.cs b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/Services/IVideoLibraryService.cs new file mode 100644 index 00000000..cea13727 --- /dev/null +++ b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/Services/IVideoLibraryService.cs @@ -0,0 +1,24 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Domain.Core.Aggregates.VideoLibrary.MovieLibraryAggregate.Services; +using Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.Services; +#endregion + +namespace Lumina.Domain.Core.Aggregates.VideoLibrary.Services; + +/// +/// Interface for the service for managing video content. +/// +public interface IVideoLibraryService +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the service for managing a movie library. + /// + public IMovieLibraryService MovieLibraryService { get; } + + /// + /// Gets the service for managing a TV shows library. + /// + public ITvShowLibraryService TvShowLibraryService { get; } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Domain/Core/Aggregates/VideoLibrary/Services/VideoLibraryService.cs b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/Services/VideoLibraryService.cs new file mode 100644 index 00000000..d1170de8 --- /dev/null +++ b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/Services/VideoLibraryService.cs @@ -0,0 +1,40 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Domain.Core.Aggregates.VideoLibrary.MovieLibraryAggregate.Services; +using Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.Services; +#endregion + +namespace Lumina.Domain.Core.Aggregates.VideoLibrary.Services; + +/// +/// Service for managing video content. +/// +public class VideoLibraryService : IVideoLibraryService +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the service for managing a movie library. + /// + public IMovieLibraryService MovieLibraryService { get; private set; } + + /// + /// Gets the service for managing a TV shows library. + /// + public ITvShowLibraryService TvShowLibraryService { get; private set; } + #endregion + + #region ====================================================================== CTOR ===================================================================================== + /// + /// Initializes a new instance of the class. + /// + /// Injected movie library service. + /// Injected TV show library service. + public VideoLibraryService(IMovieLibraryService movieLibraryService, ITvShowLibraryService tvShowLibraryService) + { + MovieLibraryService = movieLibraryService; + TvShowLibraryService = tvShowLibraryService; + } + #endregion + + #region ===================================================================== METHODS =================================================================================== + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/Entities/Episode.cs b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/Entities/Episode.cs new file mode 100644 index 00000000..700bfb79 --- /dev/null +++ b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/Entities/Episode.cs @@ -0,0 +1,16 @@ +#region ========================================================================= USING ===================================================================================== +using System.Diagnostics; +using Lumina.Domain.Common.Models.Core; +using Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.ValueObjects; +#endregion + +namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.Entities; + +/// +/// Entity for an episode. +/// +[DebuggerDisplay("{Id}: {Title}")] +public sealed class Episode : Entity +{ + +} \ No newline at end of file diff --git a/src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/Entities/Season.cs b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/Entities/Season.cs new file mode 100644 index 00000000..84a93371 --- /dev/null +++ b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/Entities/Season.cs @@ -0,0 +1,16 @@ +#region ========================================================================= USING ===================================================================================== +using System.Diagnostics; +using Lumina.Domain.Common.Models.Core; +using Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.ValueObjects; +#endregion + +namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.Entities; + +/// +/// Entity for a season. +/// +[DebuggerDisplay("{Id}: {Title}")] +public sealed class Season : Entity +{ + +} \ No newline at end of file diff --git a/src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/Services/ITvShowLibraryService.cs b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/Services/ITvShowLibraryService.cs new file mode 100644 index 00000000..c5827631 --- /dev/null +++ b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/Services/ITvShowLibraryService.cs @@ -0,0 +1,15 @@ +namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.Services +{ + /// + /// Interface for the service for managing TV show libraries. + /// + public interface ITvShowLibraryService + { + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the collection of TV shows in the library. + /// + public ICollection TvShows { get; } + #endregion + } +} \ No newline at end of file diff --git a/src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/Services/TvShowLibraryService.cs b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/Services/TvShowLibraryService.cs new file mode 100644 index 00000000..364ef76d --- /dev/null +++ b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/Services/TvShowLibraryService.cs @@ -0,0 +1,17 @@ +namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.Services; + +/// +/// Service for managing TV show libraries. +/// +public class TvShowLibraryService : ITvShowLibraryService +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the collection of TV shows in the library. + /// + public ICollection TvShows + { + get { throw new NotImplementedException(); } + } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/TvShow.cs b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/TvShow.cs new file mode 100644 index 00000000..19302372 --- /dev/null +++ b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/TvShow.cs @@ -0,0 +1,16 @@ +#region ========================================================================= USING ===================================================================================== +using System.Diagnostics; +using Lumina.Domain.Common.Models.Core; +using Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.ValueObjects; +#endregion + +namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate; + +/// +/// Entity for a TV show. +/// +[DebuggerDisplay("{Id}: {Title}")] +public sealed class TvShow : Entity +{ + +} \ No newline at end of file diff --git a/src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/ValueObjects/EpisodeId.cs b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/ValueObjects/EpisodeId.cs new file mode 100644 index 00000000..b08ee983 --- /dev/null +++ b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/ValueObjects/EpisodeId.cs @@ -0,0 +1,55 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Domain.Common.Models.Core; +#endregion + +namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.ValueObjects; + +/// +/// Value Object for the Id of an episode. +/// +public sealed class EpisodeId : ValueObject +{ + #region ==================================================================== PROPERTIES ================================================================================= + public Guid Value { get; } + #endregion + + #region ====================================================================== CTOR ===================================================================================== + /// + /// Initializes a new instance of the class. + /// + /// The value representing this object. + private EpisodeId(Guid value) + { + Value = value; + } + #endregion + + #region ===================================================================== METHODS =================================================================================== + /// + /// Creates a new instance of the class. + /// + /// The created instance. + public static EpisodeId CreateUnique() + { + // TODO: enforce invariants + return new EpisodeId(Guid.NewGuid()); + } + + /// + /// Creates a new instance of the class, from a pre-existing . + /// + /// The value used to create the instance. + /// The created instance. + public static EpisodeId Create(Guid value) + { + // TODO: enforce invariants + return new EpisodeId(value); + } + + /// + public override IEnumerable GetEqualityComponents() + { + yield return Value; + } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Domain/Common/ValueObjects/Media/PersonId.cs b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/ValueObjects/SeasonId.cs similarity index 63% rename from src/Lumina.Domain/Common/ValueObjects/Media/PersonId.cs rename to src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/ValueObjects/SeasonId.cs index 52b51af2..775b649d 100644 --- a/src/Lumina.Domain/Common/ValueObjects/Media/PersonId.cs +++ b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/ValueObjects/SeasonId.cs @@ -2,12 +2,12 @@ using Lumina.Domain.Common.Models.Core; #endregion -namespace Lumina.Domain.Common.ValueObjects.Media; +namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.ValueObjects; /// -/// Value Object for the Id of a person. +/// Value Object for the Id of a season. /// -public sealed class PersonId : ValueObject +public sealed class SeasonId : ValueObject { #region ==================================================================== PROPERTIES ================================================================================= public Guid Value { get; } @@ -15,10 +15,10 @@ public sealed class PersonId : ValueObject #region ====================================================================== CTOR ===================================================================================== /// - /// Overload C-tor. + /// Initializes a new instance of the class. /// /// The value representing this object. - private PersonId(Guid value) + private SeasonId(Guid value) { Value = value; } @@ -26,24 +26,24 @@ public sealed class PersonId : ValueObject #region ===================================================================== METHODS =================================================================================== /// - /// Creates a new instance of . + /// Creates a new instance of the class. /// - /// The created instance. - public static PersonId CreateUnique() + /// The created instance. + public static SeasonId CreateUnique() { // TODO: enforce invariants - return new PersonId(Guid.NewGuid()); + return new SeasonId(Guid.NewGuid()); } /// - /// Creates a new instance of from . + /// Creates a new instance of the class, from a pre-existing . /// - /// The value used to create the instance. - /// The created instance. - public static PersonId Create(Guid value) + /// The value used to create the instance. + /// The created instance. + public static SeasonId Create(Guid value) { // TODO: enforce invariants - return new PersonId(value); + return new SeasonId(value); } /// diff --git a/src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/ValueObjects/TvShowId.cs b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/ValueObjects/TvShowId.cs new file mode 100644 index 00000000..6ec9ccd6 --- /dev/null +++ b/src/Lumina.Domain/Core/Aggregates/VideoLibrary/TvShowLibraryAggregate/ValueObjects/TvShowId.cs @@ -0,0 +1,55 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Domain.Common.Models.Core; +#endregion + +namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.ValueObjects; + +/// +/// Value Object for the Id of a TV show. +/// +public sealed class TvShowId : ValueObject +{ + #region ==================================================================== PROPERTIES ================================================================================= + public Guid Value { get; } + #endregion + + #region ====================================================================== CTOR ===================================================================================== + /// + /// Initializes a new instance of the class. + /// + /// The value representing this object. + private TvShowId(Guid value) + { + Value = value; + } + #endregion + + #region ===================================================================== METHODS =================================================================================== + /// + /// Creates a new instance of the class. + /// + /// The created instance. + public static TvShowId CreateUnique() + { + // TODO: enforce invariants + return new TvShowId(Guid.NewGuid()); + } + + /// + /// Creates a new instance of the class, from a pre-existing . + /// + /// The value used to create the instance. + /// The created instance. + public static TvShowId Create(Guid value) + { + // TODO: enforce invariants + return new TvShowId(value); + } + + /// + public override IEnumerable GetEqualityComponents() + { + yield return Value; + } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/Book.cs b/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/Book.cs new file mode 100644 index 00000000..07a27396 --- /dev/null +++ b/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/Book.cs @@ -0,0 +1,336 @@ +#region ========================================================================= USING ===================================================================================== +using System.Diagnostics; +using ErrorOr; +using Lumina.Domain.Common.Enums; +using Lumina.Domain.Common.Models.Core; +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.ValueObjects; +#endregion + +namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate; + +/// +/// Entity for a book. +/// +[DebuggerDisplay("{Id}: {Title}")] +public sealed class Book : Entity +{ + #region ================================================================== FIELD MEMBERS ================================================================================ + private readonly List _contributors; + private readonly List _ratings; + private readonly List _isbns; + #endregion + + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the written content metadata of the book. + /// + public WrittenContentMetadata Metadata { get; private set; } + + /// + /// Gets the format of the book (e.g., Hardcover, Paperback). + /// + public BookFormat Format { get; private set; } + + /// + /// Gets the edition of the book, if applicable. + /// + public Optional Edition { get; private set; } + + /// + /// Gets the volume or book number in the series, if applicable. + /// + public Optional VolumeNumber { get; private set; } + + /// + /// Gets the series name, if the book is part of a series. + /// + public Optional Series { get; private set; } + + /// + /// Gets the ASIN (Amazon Standard Identification Number) of the book. + /// + public Optional ASIN { get; private set; } + + /// + /// Gets the Goodreads ID of the book. + /// + public Optional GoodreadsId { get; private set; } + + /// + /// Gets the Library of Congress Control Number (LCCN) of the book. + /// + public Optional LCCN { get; private set; } + + /// + /// Gets the OCLC Number (WorldCat identifier) of the book. + /// + public Optional OCLCNumber { get; private set; } + + /// + /// Gets the Open Library ID of the book. + /// + public Optional OpenLibraryId { get; private set; } + + /// + /// Gets the LibraryThing ID of the book. + /// + public Optional LibraryThingId { get; private set; } + + /// + /// Gets the Google Books ID of the book. + /// + public Optional GoogleBooksId { get; private set; } + + /// + /// Gets the Barnes & Noble ID of the book. + /// + public Optional BarnesAndNobleId { get; private set; } + + /// + /// Gets the Kobo ID of the book. + /// + public Optional KoboId { get; private set; } + + /// + /// Gets the Apple Books ID of the book. + /// + public Optional AppleBooksId { get; private set; } + + /// + /// Gets the list of ISBN (International Standard Book Number) of the book. + /// + public IReadOnlyCollection ISBNs + { + get { return _isbns.AsReadOnly(); } + } + + /// + /// Gets the list of media contributors (actors, directors, etc) starring in this book. + /// + public IReadOnlyCollection Contributors + { + get { return _contributors.AsReadOnly(); } + } + + /// + /// Gets the list of ratings for this book. + /// + public IReadOnlyCollection Ratings + { + get { return _ratings.AsReadOnly(); } + } + #endregion + + #region ====================================================================== CTOR ===================================================================================== + /// + /// Initializes a new instance of the class. + /// + /// The unique identifier of the book. + /// The metadata of the book. + /// The format of the book (e.g., Hardcover, Paperback). + /// The optional edition of the book. + /// The optional volume or book number in the series. + /// The optional series name, if the book is part of a series. + /// The optional ASIN of the book. + /// The optional Goodreads ID of the book. + /// The optional LCCN of the book. + /// The optional OCLC Number of the book. + /// The optional Open Library ID of the book. + /// The optional LibraryThing ID of the book. + /// The optional Google Books ID of the book. + /// The optional Barnes & Noble ID of the book. + /// The optional Kobo ID of the book. + /// The optional Apple Books ID of the book. + /// The list of ISBNs of the book. + /// The list of media contributors of the book. + /// The list of ratings for the book. + public Book( + BookId id, + WrittenContentMetadata metadata, + BookFormat format, + Optional edition, + Optional volumeNumber, + Optional series, + Optional asin, + Optional goodreadsId, + Optional lccn, + Optional oclcNumber, + Optional openLibraryId, + Optional libraryThingId, + Optional googleBooksId, + Optional barnesAndNobleId, + Optional koboId, + Optional appleBooksId, + List isbns, + List contributors, + List ratings) : base(id) + { + Id = id; + Metadata = metadata; + Format = format; + Edition = edition; + VolumeNumber = volumeNumber; + Series = series; + ASIN = asin; + GoodreadsId = goodreadsId; + LCCN = lccn; + OCLCNumber = oclcNumber; + OpenLibraryId = openLibraryId; + LibraryThingId = libraryThingId; + GoogleBooksId = googleBooksId; + BarnesAndNobleId = barnesAndNobleId; + KoboId = koboId; + AppleBooksId = appleBooksId; + _isbns = isbns; + _contributors = contributors; + _ratings = ratings; + } + +#pragma warning disable CS8618 + /// + /// Initializes a new instance of the class. + /// + private Book() // only needed during reflection + { + + } +#pragma warning restore CS8618 + #endregion + + #region ===================================================================== METHODS =================================================================================== + /// + /// Creates a new instance of the class. + /// + /// The metadata of the book. + /// The format of the book (e.g., Hardcover, Paperback). + /// The optional edition of the book. + /// The optional volume or book number in the series. + /// The optional series name, if the book is part of a series. + /// The optional ASIN of the book. + /// The optional Goodreads ID of the book. + /// The optional LCCN of the book. + /// The optional OCLC Number of the book. + /// The optional Open Library ID of the book. + /// The optional LibraryThing ID of the book. + /// The optional Google Books ID of the book. + /// The optional Barnes & Noble ID of the book. + /// The optional Kobo ID of the book. + /// The optional Apple Books ID of the book. + /// The list of ISBNs of the book. + /// The list of media contributors of the book. + /// The list of ratings for the book. + /// The created . + public static ErrorOr Create( + WrittenContentMetadata metadata, + BookFormat format, + Optional edition, + Optional volumeNumber, + Optional series, + Optional asin, + Optional goodreadsId, + Optional lccn, + Optional oclcNumber, + Optional openLibraryId, + Optional libraryThingId, + Optional googleBooksId, + Optional barnesAndNobleId, + Optional koboId, + Optional appleBooksId, + List isbns, + List contributors, + List ratings) + { + // TODO: enforce invariants + return new Book( + BookId.CreateUnique(), + metadata, + format, + edition, + volumeNumber, + series, + asin, + goodreadsId, + lccn, + oclcNumber, + openLibraryId, + libraryThingId, + googleBooksId, + barnesAndNobleId, + koboId, + appleBooksId, + isbns, + contributors, + ratings); + } + + /// + /// Creates a new instance of the , with a pre-existing . + /// + /// The object representing the id of the book. + /// The metadata of the book. + /// The format of the book (e.g., Hardcover, Paperback). + /// The optional edition of the book. + /// The optional volume or book number in the series. + /// The optional series name, if the book is part of a series. + /// The optional ASIN of the book. + /// The optional Goodreads ID of the book. + /// The optional LCCN of the book. + /// The optional OCLC Number of the book. + /// The optional Open Library ID of the book. + /// The optional LibraryThing ID of the book. + /// The optional Google Books ID of the book. + /// The optional Barnes & Noble ID of the book. + /// The optional Kobo ID of the book. + /// The optional Apple Books ID of the book. + /// The list of ISBNs of the book. + /// The list of media contributors of the book. + /// The list of ratings for the book. + /// The created . + public static ErrorOr Create( + BookId id, + WrittenContentMetadata metadata, + BookFormat format, + Optional edition, + Optional volumeNumber, + Optional series, + Optional asin, + Optional goodreadsId, + Optional lccn, + Optional oclcNumber, + Optional openLibraryId, + Optional libraryThingId, + Optional googleBooksId, + Optional barnesAndNobleId, + Optional koboId, + Optional appleBooksId, + List isbns, + List contributors, + List ratings) + { + // TODO: enforce invariants + return new Book( + id, + metadata, + format, + edition, + volumeNumber, + series, + asin, + goodreadsId, + lccn, + oclcNumber, + openLibraryId, + libraryThingId, + googleBooksId, + barnesAndNobleId, + koboId, + appleBooksId, + isbns, + contributors, + ratings); + } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/Services/BookLibraryService.cs b/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/Services/BookLibraryService.cs new file mode 100644 index 00000000..1973e39f --- /dev/null +++ b/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/Services/BookLibraryService.cs @@ -0,0 +1,17 @@ +namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.Services; + +/// +/// Service for managing book libraries. +/// +public sealed class BookLibraryService : IBookLibraryService +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the collection of books in the library. + /// + public ICollection Books + { + get { throw new NotImplementedException(); } + } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/Services/IBookLibraryService.cs b/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/Services/IBookLibraryService.cs new file mode 100644 index 00000000..d3eb478b --- /dev/null +++ b/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/Services/IBookLibraryService.cs @@ -0,0 +1,23 @@ +namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.Services; + +/// +/// Service for managing book libraries. +/// +public interface IBookLibraryService +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the collection of books in the library. + /// + ICollection Books { get; } + + // ICollection Series { get; } + #endregion + + // void AddBook(Book book); + // void RemoveBook(Guid bookId); + // void AddSeries(BookSeries series); + // void RemoveSeries(Guid seriesId); + // Book GetBook(Guid bookId); + // BookSeries GetSeries(Guid seriesId); +} \ No newline at end of file diff --git a/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/ValueObjects/BookId.cs b/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/ValueObjects/BookId.cs new file mode 100644 index 00000000..0011cb4b --- /dev/null +++ b/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/ValueObjects/BookId.cs @@ -0,0 +1,55 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Domain.Common.Models.Core; +#endregion + +namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects; + +/// +/// Value Object for the Id of a book. +/// +public sealed class BookId : ValueObject +{ + #region ==================================================================== PROPERTIES ================================================================================= + public Guid Value { get; } + #endregion + + #region ====================================================================== CTOR ===================================================================================== + /// + /// Initializes a new instance of the class. + /// + /// The value representing this object. + private BookId(Guid value) + { + Value = value; + } + #endregion + + #region ===================================================================== METHODS =================================================================================== + /// + /// Creates a new instance of the class. + /// + /// The created instance. + public static BookId CreateUnique() + { + // TODO: enforce invariants + return new BookId(Guid.NewGuid()); + } + + /// + /// Creates a new instance of the class, from a pre-existing . + /// + /// The value used to create the instance. + /// The created instance. + public static BookId Create(Guid value) + { + // TODO: enforce invariants + return new BookId(value); + } + + /// + public override IEnumerable GetEqualityComponents() + { + yield return Value; + } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/ValueObjects/BookLibraryId.cs b/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/ValueObjects/BookLibraryId.cs new file mode 100644 index 00000000..a54b0b0e --- /dev/null +++ b/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/ValueObjects/BookLibraryId.cs @@ -0,0 +1,56 @@ +#region ========================================================================= USING ===================================================================================== +using ErrorOr; +using Lumina.Domain.Common.Models.Core; +#endregion + +namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects; + +/// +/// Value Object for the Id of a book library. +/// +public sealed class BookLibraryId : ValueObject +{ + #region ==================================================================== PROPERTIES ================================================================================= + public Guid Value { get; } + #endregion + + #region ====================================================================== CTOR ===================================================================================== + /// + /// Initializes a new instance of the class. + /// + /// The value representing this object. + private BookLibraryId(Guid value) + { + Value = value; + } + #endregion + + #region ===================================================================== METHODS =================================================================================== + /// + /// Creates a new instance of the class. + /// + /// The created instance. + public static ErrorOr CreateUnique() + { + // TODO: enforce invariants + return new BookLibraryId(Guid.NewGuid()); + } + + /// + /// Creates a new instance of the class, from a pre-existing . + /// + /// The value used to create the instance. + /// The created instance. + public static ErrorOr Create(Guid value) + { + // TODO: enforce invariants + return new BookLibraryId(value); + } + + /// + public override IEnumerable GetEqualityComponents() + { + yield return Value; + } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/ValueObjects/Isbn.cs b/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/ValueObjects/Isbn.cs new file mode 100644 index 00000000..b431d9ee --- /dev/null +++ b/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/ValueObjects/Isbn.cs @@ -0,0 +1,136 @@ +#region ========================================================================= USING ===================================================================================== +using System.Text.RegularExpressions; +using ErrorOr; +using Lumina.Domain.Common.Enums; +using Lumina.Domain.Common.Models.Core; +using Lumina.Domain.Common.Errors; +#endregion + +namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects; + +/// +/// Value Object for the ISBN of a book. +/// +public sealed class Isbn : ValueObject +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the value of the ISBN. + /// + public string Value { get; private set; } + + /// + /// Gets the format of the ISBN. + /// + public IsbnFormat Format { get; private set; } + #endregion + + #region ====================================================================== CTOR ===================================================================================== + /// + /// Initializes a new instance of the class. + /// + /// The value representing this object. + /// The format of the ISBN representing this object. + private Isbn(string value, IsbnFormat format) + { + Value = value; + Format = format; + } + #endregion + + #region ===================================================================== METHODS =================================================================================== + /// + /// Creates a new instance of the class. + /// + /// The value representing this object. + /// The format of the ISBN representing this object. + /// The created instance. + public static ErrorOr Create(string value, IsbnFormat format) + { + // enforce invariants + if (string.IsNullOrWhiteSpace(value)) + return Errors.WrittenContent.IsbnCannotBeEmpty; + // remove hyphens and spaces, for validation + string cleanedValue = Regex.Replace(value, @"[-\s]", string.Empty); + switch (format) + { + case IsbnFormat.Isbn10: + if (!IsValidIsbn10(cleanedValue)) + return Errors.WrittenContent.InvalidIsbn10Format; + break; + case IsbnFormat.Isbn13: + if (!IsValidIsbn13(cleanedValue)) + return Errors.WrittenContent.InvalidIsbn13Format; + break; + default: + return Errors.WrittenContent.UnknownIsbnFormat; + } + return new Isbn(value, format); + } + + /// + /// Validates an ISBN-10 string. + /// + /// The ISBN-10 string to validate, without hyphens or spaces. + /// if the ISBN-10 is valid, otherwise. + public static bool IsValidIsbn10(string isbn) + { + // ISBN-10 must be exactly 10 characters long + if (isbn.Length != 10) + return false; + int sum = 0; + for (int i = 0; i < 9; i++) + { + // each of the first 9 characters must be a digit + if (!char.IsDigit(isbn[i])) + return false; + // calculate the sum: each digit is multiplied by its position (10 to 2) and added + sum += (10 - i) * (isbn[i] - '0'); + } + // check the last character, which can be a digit or 'X' + char lastChar = isbn[9]; + if (lastChar == 'X' || lastChar == 'x') + sum += 10; + else if (char.IsDigit(lastChar)) + sum += lastChar - '0'; + else + return false; + // the ISBN-10 is valid if the sum is divisible by 11 + return sum % 11 == 0; + } + + /// + /// Validates an ISBN-13 string. + /// + /// The ISBN-13 string to validate, without hyphens or spaces. + /// if the ISBN-13 is valid, otherwise. + public static bool IsValidIsbn13(string isbn) + { + // ISBN-13 must be exactly 13 characters long + if (isbn.Length != 13) + return false; + int sum = 0; + for (int i = 0; i < 12; i++) + { + // each of the first 12 characters must be a digit + if (!char.IsDigit(isbn[i])) + return false; + // calculate the sum: alternate digits are multiplied by 3 + sum += (i % 2 == 0) ? isbn[i] - '0' : 3 * (isbn[i] - '0'); + } + // calculate the check digit + int checkDigit = 10 - (sum % 10); + if (checkDigit == 10) + checkDigit = 0; + // the ISBN-13 is valid if the calculated check digit matches the last digit + return checkDigit == (isbn[12] - '0'); + } + + /// + public override IEnumerable GetEqualityComponents() + { + yield return Value; + yield return Format; + } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/ValueObjects/WrittenContentMetadata.cs b/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/ValueObjects/WrittenContentMetadata.cs new file mode 100644 index 00000000..ec747821 --- /dev/null +++ b/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/ValueObjects/WrittenContentMetadata.cs @@ -0,0 +1,69 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Domain.Common.Primitives; +using Lumina.Domain.Common.ValueObjects.Metadata; +using System.Diagnostics; +#endregion + +namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects; + +/// +/// Value Object for the metadata of a written media element. +/// +[DebuggerDisplay("{Title}")] +public class WrittenContentMetadata : BaseMetadata +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the publisher of the written content. + /// + public Optional Publisher { get; } + + /// + /// Gets the number of pages in the written content. + /// + public Optional PageCount { get; } + #endregion + + #region ====================================================================== CTOR ===================================================================================== + /// + /// Initializes a new instance of the class. + /// + /// The title of the written content. + /// The optional original title of the video. + /// The release information of the written content. + /// The description of the written content. + /// The genres of the written content. + /// The tags associated with the written content. + /// The language of the written content. + /// The optional original language of the video. + /// The publisher of the written content. + /// The number of pages in the written content. + public WrittenContentMetadata( + string title, + Optional originalTitle, + ReleaseInfo release, + Optional description, + List genres, + List tags, + Optional language, + Optional originalLanguage, + Optional publisher, + Optional pageCount) + : base(title, originalTitle, release, description, genres, tags, language, originalLanguage) + { + Publisher = publisher; + PageCount = pageCount; + } + #endregion + + #region ===================================================================== METHODS =================================================================================== + /// + public override IEnumerable GetEqualityComponents() + { + foreach (var component in base.GetEqualityComponents()) + yield return component; + yield return Publisher; + yield return PageCount; + } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/Services/IWrittenContentLibraryService.cs b/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/Services/IWrittenContentLibraryService.cs new file mode 100644 index 00000000..7b9eb60a --- /dev/null +++ b/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/Services/IWrittenContentLibraryService.cs @@ -0,0 +1,18 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.Services; +#endregion + +namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.Services; + +/// +/// Interface for the service for managing written content. +/// +public interface IWrittenContentLibraryService +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the service for managing book libraries. + /// + public IBookLibraryService BookLibraryService { get; } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/Services/WrittenContentLibraryService.cs b/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/Services/WrittenContentLibraryService.cs new file mode 100644 index 00000000..64d40632 --- /dev/null +++ b/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/Services/WrittenContentLibraryService.cs @@ -0,0 +1,32 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.Services; +#endregion + +namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.Services; + +/// +/// Service for managing written content. +/// +public class WrittenContentLibraryService : IWrittenContentLibraryService +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the service for managing book libraries. + /// + public IBookLibraryService BookLibraryService { get; private set; } + #endregion + + #region ====================================================================== CTOR ===================================================================================== + /// + /// Initializes a new instance of the class. + /// + /// Injected book library service. + public WrittenContentLibraryService(IBookLibraryService bookLibraryService) + { + BookLibraryService = bookLibraryService; + } + #endregion + + #region ===================================================================== METHODS =================================================================================== + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Domain/Core/Services/IMediaLibraryService.cs b/src/Lumina.Domain/Core/Services/IMediaLibraryService.cs new file mode 100644 index 00000000..dd2b39ea --- /dev/null +++ b/src/Lumina.Domain/Core/Services/IMediaLibraryService.cs @@ -0,0 +1,29 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Domain.Core.Aggregates.VideoLibrary.Services; +using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.Services; +#endregion + +namespace Lumina.Domain.Core.Services; + +/// +/// Interface for the service for managing a media library. +/// +public interface IMediaLibraryService +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the service for managing a audio library. + /// + //public IAudioLibraryService AudioLibraryService { get; } + + /// + /// Gets the service for managing a video library. + /// + public IVideoLibraryService VideoLibraryService { get; } + + /// + /// Gets the service for managing a written content library. + /// + public IWrittenContentLibraryService WrittenContentLibraryService { get; } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Domain/Core/Services/MediaLibraryService.cs b/src/Lumina.Domain/Core/Services/MediaLibraryService.cs new file mode 100644 index 00000000..12616d12 --- /dev/null +++ b/src/Lumina.Domain/Core/Services/MediaLibraryService.cs @@ -0,0 +1,37 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Domain.Core.Aggregates.VideoLibrary.Services; +using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.Services; +#endregion + +namespace Lumina.Domain.Core.Services; + +/// +/// Service for managing media libraries. +/// +public class MediaLibraryService : IMediaLibraryService +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the service for managing a video library. + /// + public IVideoLibraryService VideoLibraryService { get; private set; } + + /// + /// Gets the service for managing a written content library. + /// + public IWrittenContentLibraryService WrittenContentLibraryService { get; private set; } + #endregion + + #region ====================================================================== CTOR ===================================================================================== + /// + /// Initializes a new instance of the class. + /// + /// Injected video library service. + /// Injected written content library service. + public MediaLibraryService(IVideoLibraryService videoLibraryService, IWrittenContentLibraryService writtenContentLibraryService) + { + VideoLibraryService = videoLibraryService; + WrittenContentLibraryService = writtenContentLibraryService; + } + #endregion +} \ No newline at end of file