mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 11:11:10 +00:00
Replaces ErrorOr library with a custom implementation.
This commit is contained in:
1 parent
8fe90a4dde
commit
3b772d68ca
436 files changed
+4234
-3922
No files matched your search
+10
-10
@@ -1,6 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.SharedKernel.Common.Errors;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
@@ -56,9 +56,9 @@ public sealed class BookSeries : Entity<BookSeriesId>
|
||||
/// <param name="isComplete">The current status of the book series.</param>
|
||||
/// <param name="books">The books of the book series.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="BookSeries"/>, or an error message.
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="BookSeries"/>, or an error message.
|
||||
/// </returns>
|
||||
public static ErrorOr<BookSeries> Create(
|
||||
public static Result<BookSeries> Create(
|
||||
BookSeriesId id,
|
||||
WrittenContentMetadata metadata,
|
||||
bool isComplete,
|
||||
@@ -80,9 +80,9 @@ public sealed class BookSeries : Entity<BookSeriesId>
|
||||
/// <param name="isComplete">The current status of the book series.</param>
|
||||
/// <param name="books">The books of the book series.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="BookSeries"/>, or an error message.
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="BookSeries"/>, or an error message.
|
||||
/// </returns>
|
||||
public static ErrorOr<BookSeries> Create(
|
||||
public static Result<BookSeries> Create(
|
||||
WrittenContentMetadata metadata,
|
||||
bool isComplete,
|
||||
List<Book> books)
|
||||
@@ -99,8 +99,8 @@ public sealed class BookSeries : Entity<BookSeriesId>
|
||||
/// Adds a book to the series.
|
||||
/// </summary>
|
||||
/// <param name="book">The book to be added.</param>
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
public ErrorOr<Created> AddBook(Book book)
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
public Result<Created> AddBook(Book book)
|
||||
{
|
||||
if (_books.Contains(book))
|
||||
return Errors.WrittenContent.TheBookIsAlreadyInTheSeries;
|
||||
@@ -112,8 +112,8 @@ public sealed class BookSeries : Entity<BookSeriesId>
|
||||
/// Removes a book from the series.
|
||||
/// </summary>
|
||||
/// <param name="book">The book to be removed.</param>
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
public ErrorOr<Deleted> RemoveBook(Book book)
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
public Result<Deleted> RemoveBook(Book book)
|
||||
{
|
||||
if (!_books.Contains(book))
|
||||
return Errors.WrittenContent.TheBookIsNotInTheSeries;
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -26,7 +26,7 @@ public sealed class BookLibraryId : EntityId<Guid> // TODO: to be removed
|
||||
/// Creates a new instance of the <see cref="BookLibraryId"/> class.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="BookLibraryId"/> instance.</returns>
|
||||
public static ErrorOr<BookLibraryId> CreateUnique()
|
||||
public static Result<BookLibraryId> CreateUnique()
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new BookLibraryId(Guid.NewGuid());
|
||||
@@ -37,7 +37,7 @@ public sealed class BookLibraryId : EntityId<Guid> // TODO: to be removed
|
||||
/// </summary>
|
||||
/// <param name="value">The value used to create the <see cref="BookLibraryId"/> instance.</param>
|
||||
/// <returns>The created <see cref="BookLibraryId"/> instance.</returns>
|
||||
public static ErrorOr<BookLibraryId> Create(Guid value)
|
||||
public static Result<BookLibraryId> Create(Guid value)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new BookLibraryId(value);
|
||||
|
||||
+4
-5
@@ -1,9 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Errors;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
@@ -42,9 +41,9 @@ public class BookRating : Rating
|
||||
/// <param name="source">The optional source of the rating.</param>
|
||||
/// <param name="voteCount">The optional number of votes or reviews.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="Rating"/>, or an error message.
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="Rating"/>, or an error message.
|
||||
/// </returns>
|
||||
public static ErrorOr<BookRating> Create(decimal value, decimal maxValue, Optional<BookRatingSource> source, Optional<int> voteCount)
|
||||
public static Result<BookRating> Create(decimal value, decimal maxValue, Optional<BookRatingSource> source, Optional<int> voteCount)
|
||||
{
|
||||
if (maxValue < 0 || value < 0)
|
||||
return Errors.Metadata.RatingValueMustBePositive;
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Errors;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@@ -46,7 +46,7 @@ public sealed class Isbn : ValueObject
|
||||
/// <param name="value">The value representing this object.</param>
|
||||
/// <param name="format">The format of the ISBN representing this object.</param>
|
||||
/// <returns>The created <see cref="Isbn"/> instance.</returns>
|
||||
public static ErrorOr<Isbn> Create(string? value, IsbnFormat format)
|
||||
public static Result<Isbn> Create(string? value, IsbnFormat format)
|
||||
{
|
||||
// enforce invariants
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
|
||||
+2
-4
@@ -1,6 +1,4 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.SharedKernel.Common.Errors;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System.Collections.Generic;
|
||||
@@ -69,9 +67,9 @@ public class WrittenContentMetadata : BaseMetadata
|
||||
/// <param name="publisher">The publisher of the written content, if applicable.</param>
|
||||
/// <param name="pageCount">The number of pages in the written content, if applicable.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="WrittenContentMetadata"/>, or an error message.
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="WrittenContentMetadata"/>, or an error message.
|
||||
/// </returns>
|
||||
public static ErrorOr<WrittenContentMetadata> Create(
|
||||
public static Result<WrittenContentMetadata> Create(
|
||||
string title,
|
||||
Optional<string> originalTitle,
|
||||
Optional<string> description,
|
||||
|
||||
Reference in new issue
Block a user