mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 07:11:10 +00:00
Refactors the book slice across the stack
This commit is contained in:
1 parent
54cae054c1
commit
c112c64c25
8 files changed
+272
-38
No files matched your search
+3
-2
@@ -71,8 +71,9 @@ public static class BookMapping
|
||||
Ratings = [.. domainEntity.Ratings.ToRepositoryEntities()],
|
||||
CreatedOnUtc = domainEntity.CreatedOnUtc,
|
||||
CreatedBy = Guid.Empty,
|
||||
UpdatedOnUtc = domainEntity.UpdatedOnUtc.HasValue ? domainEntity.UpdatedOnUtc : null,
|
||||
UpdatedBy = domainEntity.UpdatedOnUtc.HasValue ? Guid.NewGuid() : null,
|
||||
// The audit columns are owned by the auditing interceptor, which stamps only the rows that actually changed, so they are never mapped here.
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -34,12 +34,12 @@ public static class UpdateBookCommandMapping
|
||||
public static Result<Book> ToDomainEntity(this UpdateBookCommand command, BookEntity existingBook)
|
||||
{
|
||||
IEnumerable<Result<BookRating>> domainRatingsResult = command.Ratings!.ToDomainEntities();
|
||||
List<Error> errors = [.. domainRatingsResult.Where(ratingResult => ratingResult.IsFailure).SelectMany(ratingResult => ratingResult.Errors) ?? []];
|
||||
List<Error> errors = [.. domainRatingsResult.Where(ratingResult => ratingResult.IsFailure).SelectMany(ratingResult => ratingResult.Errors)];
|
||||
if (errors.Count > 0)
|
||||
return errors;
|
||||
|
||||
IEnumerable<Result<Isbn>> domainIsbnsResult = command.ISBNs!.ToDomainEntities();
|
||||
errors = [.. domainIsbnsResult.Where(isbnResult => isbnResult.IsFailure).SelectMany(isbnResult => isbnResult.Errors) ?? []];
|
||||
errors = [.. domainIsbnsResult.Where(isbnResult => isbnResult.IsFailure).SelectMany(isbnResult => isbnResult.Errors)];
|
||||
if (errors.Count > 0)
|
||||
return errors;
|
||||
|
||||
@@ -57,7 +57,7 @@ public static class UpdateBookCommandMapping
|
||||
|
||||
// Map the media contributors referenced by the user to their domain counterparts; a contributor is identified by its id and carries the role it played.
|
||||
IEnumerable<Result<BookMediaContributor>> domainContributorsResult = command.Contributors!.ToBookDomainEntities();
|
||||
errors = [.. domainContributorsResult.Where(domainContributor => domainContributor.IsFailure).SelectMany(domainContributor => domainContributor.Errors) ?? []];
|
||||
errors = [.. domainContributorsResult.Where(domainContributor => domainContributor.IsFailure).SelectMany(domainContributor => domainContributor.Errors)];
|
||||
if (errors.Count > 0)
|
||||
return errors;
|
||||
|
||||
|
||||
+2
-2
@@ -30,12 +30,12 @@ public static class WrittenContentMetadataDtoMapping
|
||||
return domainReleaseInfoResult.Value.Errors;
|
||||
|
||||
IEnumerable<Result<Genre>> domainGenresResult = dto.Genres!.ToDomainEntities();
|
||||
List<Error> errors = [.. domainGenresResult.Where(genreResult => genreResult.IsFailure).SelectMany(genreResult => genreResult.Errors) ?? []];
|
||||
List<Error> errors = [.. domainGenresResult.Where(genreResult => genreResult.IsFailure).SelectMany(genreResult => genreResult.Errors)];
|
||||
if (errors.Count > 0)
|
||||
return errors;
|
||||
|
||||
IEnumerable<Result<Tag>> domainTagsResult = dto.Tags!.ToDomainEntities();
|
||||
errors = [.. domainTagsResult.Where(tagResult => tagResult.IsFailure).SelectMany(tagResult => tagResult.Errors) ?? []];
|
||||
errors = [.. domainTagsResult.Where(tagResult => tagResult.IsFailure).SelectMany(tagResult => tagResult.Errors)];
|
||||
if (errors.Count > 0)
|
||||
return errors;
|
||||
|
||||
|
||||
Reference in new issue
Block a user