mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-02 15:11:10 +00:00
Adds refactoring
This commit is contained in:
1 parent
ed0d341513
commit
b9dcb831e9
10 files changed
+184
-102
No files matched your search
@@ -21,7 +21,6 @@ public record BookDto(
|
||||
string? LibraryThingId,
|
||||
string? GoogleBooksId,
|
||||
string? BarnesAndNobleId,
|
||||
string? KoboId,
|
||||
string? AppleBooksId,
|
||||
List<IsbnDto> ISBNs,
|
||||
List<Guid> Contributors,
|
||||
|
||||
-1
@@ -26,7 +26,6 @@ public record AddBookCommand(
|
||||
string? LibraryThingId,
|
||||
string? GoogleBooksId,
|
||||
string? BarnesAndNobleId,
|
||||
string? KoboId,
|
||||
string? AppleBooksId,
|
||||
List<IsbnDto> ISBNs,
|
||||
List<MediaContributorDto> Contributors,
|
||||
|
||||
+1
-1
@@ -28,6 +28,7 @@ public class AddBookCommandHandler : IRequestHandler<AddBookCommand, ErrorOr<Boo
|
||||
/// </returns>
|
||||
public async ValueTask<ErrorOr<Book>> Handle(AddBookCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
// TODO: update Api.Book.md documentation when the functionality is fully implemented
|
||||
List<MediaContributorId> contributorIds = new();
|
||||
foreach(var mediaContributor in request.Contributors)
|
||||
{
|
||||
@@ -129,7 +130,6 @@ public class AddBookCommandHandler : IRequestHandler<AddBookCommand, ErrorOr<Boo
|
||||
Optional<string>.FromNullable(request.LibraryThingId),
|
||||
Optional<string>.FromNullable(request.GoogleBooksId),
|
||||
Optional<string>.FromNullable(request.BarnesAndNobleId),
|
||||
Optional<string>.FromNullable(request.KoboId),
|
||||
Optional<string>.FromNullable(request.AppleBooksId),
|
||||
domainIsbns,
|
||||
contributorIds,
|
||||
|
||||
+2
-7
@@ -128,11 +128,10 @@ public class AddBookCommandValidator : AbstractValidator<AddBookCommand>
|
||||
.Matches(@"^\d+$").When(x => x.GoodreadsId is not null)
|
||||
.WithMessage(Errors.WrittenContent.GoodreadsIdMustBeNumeric.Code);
|
||||
RuleFor(x => x.LCCN)
|
||||
.Length(12).WithMessage(Errors.WrittenContent.LccnMustBe12CharactersLong.Code)
|
||||
.Matches(@"^[a-z]{0,3}\d{8}$").WithMessage(Errors.WrittenContent.InvalidLccnFormat.Code)
|
||||
.Matches(@"^[a-z]{0,3}\d{8,10}$").WithMessage(Errors.WrittenContent.InvalidLccnFormat.Code)
|
||||
.When(x => x.LCCN is not null);
|
||||
RuleFor(x => x.OCLCNumber)
|
||||
.Matches(@"^(ocm\d{8} |ocn\d{9,}|\(OCoLC\)\d+)$").When(x => x.OCLCNumber is not null)
|
||||
.Matches(@"^(ocm\d{8}|ocn\d{9,}|on\d{10,}|\(OCoLC\)\d{8,}|\d{8,})$").When(x => x.OCLCNumber is not null)
|
||||
.WithMessage(Errors.WrittenContent.InvalidOclcFormat.Code);
|
||||
RuleFor(x => x.OpenLibraryId)
|
||||
.Matches(@"^OL[1-9]\d*[AMW]$").When(x => x.OpenLibraryId is not null)
|
||||
@@ -148,10 +147,6 @@ public class AddBookCommandValidator : AbstractValidator<AddBookCommand>
|
||||
.Length(10).WithMessage(Errors.WrittenContent.BarnesAndNoblesIdMustBe10CharactersLong.Code)
|
||||
.Matches(@"^\d{10}$").WithMessage(Errors.WrittenContent.InvalidBarnesAndNoblesIdFormat.Code)
|
||||
.When(x => x.BarnesAndNobleId is not null);
|
||||
RuleFor(x => x.KoboId)
|
||||
.Matches(@"^\d+$").WithMessage(Errors.WrittenContent.KoboIdMustBeNumeric.Code)
|
||||
.Length(3, 5).WithMessage(Errors.WrittenContent.KoboIdMustBeBetween3And5CharactersLong.Code)
|
||||
.When(x => x.KoboId is not null);
|
||||
RuleFor(x => x.AppleBooksId)
|
||||
.Matches(@"^id\d+$").When(x => x.AppleBooksId is not null)
|
||||
.WithMessage(Errors.WrittenContent.InvalidAppleBooksIdFormat.Code);
|
||||
|
||||
@@ -21,7 +21,6 @@ public static partial class Errors
|
||||
public static Error TheBookIsNotInTheSeries => Error.Forbidden(nameof(TheBookIsNotInTheSeries));
|
||||
public static Error AsinMustBe10CharactersLong => Error.Validation(nameof(AsinMustBe10CharactersLong));
|
||||
public static Error GoodreadsIdMustBeNumeric => Error.Validation(nameof(GoodreadsIdMustBeNumeric));
|
||||
public static Error LccnMustBe12CharactersLong => Error.Validation(nameof(LccnMustBe12CharactersLong));
|
||||
public static Error InvalidLccnFormat => Error.Validation(nameof(InvalidLccnFormat));
|
||||
public static Error InvalidOclcFormat => Error.Validation(nameof(InvalidOclcFormat));
|
||||
public static Error InvalidOpenLibraryId => Error.Validation(nameof(InvalidOpenLibraryId));
|
||||
@@ -30,8 +29,6 @@ public static partial class Errors
|
||||
public static Error InvalidGoogleBooksIdFormat => Error.Validation(nameof(InvalidGoogleBooksIdFormat));
|
||||
public static Error BarnesAndNoblesIdMustBe10CharactersLong => Error.Validation(nameof(BarnesAndNoblesIdMustBe10CharactersLong));
|
||||
public static Error InvalidBarnesAndNoblesIdFormat => Error.Validation(nameof(InvalidBarnesAndNoblesIdFormat));
|
||||
public static Error KoboIdMustBeNumeric => Error.Validation(nameof(KoboIdMustBeNumeric));
|
||||
public static Error KoboIdMustBeBetween3And5CharactersLong => Error.Validation(nameof(KoboIdMustBeBetween3And5CharactersLong));
|
||||
public static Error InvalidAppleBooksIdFormat => Error.Validation(nameof(InvalidAppleBooksIdFormat));
|
||||
public static Error PublisherMustBeMaximum100CharactersLong => Error.Validation(nameof(PublisherMustBeMaximum100CharactersLong));
|
||||
public static Error PageCountMustBeGreaterThanZero => Error.Validation(nameof(PageCountMustBeGreaterThanZero));
|
||||
|
||||
@@ -90,11 +90,6 @@ public sealed class Book : AggregateRoot<BookId, Guid>
|
||||
/// </summary>
|
||||
public Optional<string> BarnesAndNobleId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Kobo ID of the book.
|
||||
/// </summary>
|
||||
public Optional<string> KoboId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Apple Books ID of the book.
|
||||
/// </summary>
|
||||
@@ -143,7 +138,6 @@ public sealed class Book : AggregateRoot<BookId, Guid>
|
||||
/// <param name="libraryThingId">The optional LibraryThing ID of the book.</param>
|
||||
/// <param name="googleBooksId">The optional Google Books ID of the book.</param>
|
||||
/// <param name="barnesAndNobleId">The optional Barnes & Noble ID of the book.</param>
|
||||
/// <param name="koboId">The optional Kobo ID of the book.</param>
|
||||
/// <param name="appleBooksId">The optional Apple Books ID of the book.</param>
|
||||
/// <param name="isbns">The list of ISBNs of the book.</param>
|
||||
/// <param name="contributors">The list of media contributors of the book.</param>
|
||||
@@ -163,7 +157,6 @@ public sealed class Book : AggregateRoot<BookId, Guid>
|
||||
Optional<string> libraryThingId,
|
||||
Optional<string> googleBooksId,
|
||||
Optional<string> barnesAndNobleId,
|
||||
Optional<string> koboId,
|
||||
Optional<string> appleBooksId,
|
||||
List<Isbn> isbns,
|
||||
List<MediaContributorId> contributors,
|
||||
@@ -183,7 +176,6 @@ public sealed class Book : AggregateRoot<BookId, Guid>
|
||||
LibraryThingId = libraryThingId;
|
||||
GoogleBooksId = googleBooksId;
|
||||
BarnesAndNobleId = barnesAndNobleId;
|
||||
KoboId = koboId;
|
||||
AppleBooksId = appleBooksId;
|
||||
_isbns = isbns;
|
||||
_contributors = contributors;
|
||||
@@ -218,7 +210,6 @@ public sealed class Book : AggregateRoot<BookId, Guid>
|
||||
/// <param name="libraryThingId">The optional LibraryThing ID of the book.</param>
|
||||
/// <param name="googleBooksId">The optional Google Books ID of the book.</param>
|
||||
/// <param name="barnesAndNobleId">The optional Barnes & Noble ID of the book.</param>
|
||||
/// <param name="koboId">The optional Kobo ID of the book.</param>
|
||||
/// <param name="appleBooksId">The optional Apple Books ID of the book.</param>
|
||||
/// <param name="isbns">The list of ISBNs of the book.</param>
|
||||
/// <param name="contributors">The list of media contributors of the book.</param>
|
||||
@@ -240,7 +231,6 @@ public sealed class Book : AggregateRoot<BookId, Guid>
|
||||
Optional<string> libraryThingId,
|
||||
Optional<string> googleBooksId,
|
||||
Optional<string> barnesAndNobleId,
|
||||
Optional<string> koboId,
|
||||
Optional<string> appleBooksId,
|
||||
List<Isbn> isbns,
|
||||
List<MediaContributorId> contributors,
|
||||
@@ -262,7 +252,6 @@ public sealed class Book : AggregateRoot<BookId, Guid>
|
||||
libraryThingId,
|
||||
googleBooksId,
|
||||
barnesAndNobleId,
|
||||
koboId,
|
||||
appleBooksId,
|
||||
isbns,
|
||||
contributors,
|
||||
@@ -286,7 +275,6 @@ public sealed class Book : AggregateRoot<BookId, Guid>
|
||||
/// <param name="libraryThingId">The optional LibraryThing ID of the book.</param>
|
||||
/// <param name="googleBooksId">The optional Google Books ID of the book.</param>
|
||||
/// <param name="barnesAndNobleId">The optional Barnes & Noble ID of the book.</param>
|
||||
/// <param name="koboId">The optional Kobo ID of the book.</param>
|
||||
/// <param name="appleBooksId">The optional Apple Books ID of the book.</param>
|
||||
/// <param name="isbns">The list of ISBNs of the book.</param>
|
||||
/// <param name="contributors">The list of media contributors of the book.</param>
|
||||
@@ -309,7 +297,6 @@ public sealed class Book : AggregateRoot<BookId, Guid>
|
||||
Optional<string> libraryThingId,
|
||||
Optional<string> googleBooksId,
|
||||
Optional<string> barnesAndNobleId,
|
||||
Optional<string> koboId,
|
||||
Optional<string> appleBooksId,
|
||||
List<Isbn> isbns,
|
||||
List<MediaContributorId> contributors,
|
||||
@@ -331,7 +318,6 @@ public sealed class Book : AggregateRoot<BookId, Guid>
|
||||
libraryThingId,
|
||||
googleBooksId,
|
||||
barnesAndNobleId,
|
||||
koboId,
|
||||
appleBooksId,
|
||||
isbns,
|
||||
contributors,
|
||||
|
||||
@@ -23,7 +23,6 @@ public record AddBookRequest(
|
||||
string? LibraryThingId,
|
||||
string? GoogleBooksId,
|
||||
string? BarnesAndNobleId,
|
||||
string? KoboId,
|
||||
string? AppleBooksId,
|
||||
List<IsbnDto> ISBNs,
|
||||
List<MediaContributorDto> Contributors,
|
||||
|
||||
Reference in new issue
Block a user