mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 08:11:10 +00:00
Fixes typos and replaces LINQ conversions with collection expressions
This commit is contained in:
1 parent
adadec7f3b
commit
74e9030a18
75 files changed
+113
-113
No files matched your search
+3
-3
@@ -47,7 +47,7 @@ public class GetEnabledLibrariesQueryHandler : IRequestHandler<GetEnabledLibrari
|
||||
/// <param name="request">The request to be handled.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="LibraryResponse"/>, or an error message.
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="LibraryResponse"/>, or an error message.
|
||||
/// </returns>
|
||||
public async ValueTask<ErrorOr<LibraryResponse[]>> Handle(GetEnabledLibrariesQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -63,9 +63,9 @@ public class GetEnabledLibrariesQueryHandler : IRequestHandler<GetEnabledLibrari
|
||||
else
|
||||
{
|
||||
// for regular users, only take the libraries that belong to them
|
||||
LibraryResponse[] userEnabledLibraries = getEnabledLibrariesResult.Value
|
||||
LibraryResponse[] userEnabledLibraries = [.. getEnabledLibrariesResult.Value
|
||||
.Where(library => library.UserId == _currentUserService.UserId)
|
||||
.Select(library => library.ToResponse()).ToArray();
|
||||
.Select(library => library.ToResponse())];
|
||||
|
||||
return ErrorOrFactory.From(userEnabledLibraries);
|
||||
}
|
||||
|
||||
+3
-3
@@ -47,7 +47,7 @@ public class GetLibrariesQueryHandler : IRequestHandler<GetLibrariesQuery, Error
|
||||
/// <param name="request">The request to be handled.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="LibraryResponse"/>, or an error message.
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="LibraryResponse"/>, or an error message.
|
||||
/// </returns>
|
||||
public async ValueTask<ErrorOr<LibraryResponse[]>> Handle(GetLibrariesQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -63,9 +63,9 @@ public class GetLibrariesQueryHandler : IRequestHandler<GetLibrariesQuery, Error
|
||||
else
|
||||
{
|
||||
// for regular users, only take the libraries that belong to them
|
||||
LibraryResponse[] userLibraries = getLibrariesResult.Value
|
||||
LibraryResponse[] userLibraries = [.. getLibrariesResult.Value
|
||||
.Where(library => library.UserId == _currentUserService.UserId)
|
||||
.Select(library => library.ToResponse()).ToArray();
|
||||
.Select(library => library.ToResponse())];
|
||||
|
||||
return ErrorOrFactory.From(userLibraries);
|
||||
}
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ public class GetLibraryQueryHandler : IRequestHandler<GetLibraryQuery, ErrorOr<L
|
||||
/// <param name="request">The request to be handled.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="LibraryResponse"/>, or an error message.
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="LibraryResponse"/>, or an error message.
|
||||
/// </returns>
|
||||
public async ValueTask<ErrorOr<LibraryResponse>> Handle(GetLibraryQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
+2
-2
@@ -54,7 +54,7 @@ public class GetRunningLibraryScansQueryHandler : IRequestHandler<GetRunningLibr
|
||||
/// <param name="request">The request to be handled.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="MediaLibraryScanProgress"/>, or an error message.
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="MediaLibraryScanProgress"/>, or an error message.
|
||||
/// </returns>
|
||||
public async ValueTask<ErrorOr<IEnumerable<MediaLibraryScanProgressResponse>>> Handle(GetRunningLibraryScansQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -68,7 +68,7 @@ public class GetRunningLibraryScansQueryHandler : IRequestHandler<GetRunningLibr
|
||||
LibraryScanEntity[] userRunningRepositoryLibraryScans = [];
|
||||
// admins can see all libraries
|
||||
if (!await _authorizationService.IsInRoleAsync(_currentUserService.UserId!.Value, "Admin", cancellationToken).ConfigureAwait(false))
|
||||
userRunningRepositoryLibraryScans = getRunningScansResult.Value.ToArray();
|
||||
userRunningRepositoryLibraryScans = [.. getRunningScansResult.Value];
|
||||
else // for regular users, only take the libraries that belong to them
|
||||
userRunningRepositoryLibraryScans = getRunningScansResult.Value
|
||||
.Where(libraryScan => libraryScan.UserId == _currentUserService.UserId).ToArray();
|
||||
|
||||
+9
-9
@@ -45,7 +45,7 @@ public class AddBookCommandHandler : IRequestHandler<AddBookCommand, ErrorOr<Boo
|
||||
/// <param name="request">The request to be handled.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="BookResponse"/>, or an error message.
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="BookResponse"/>, or an error message.
|
||||
/// </returns>
|
||||
public async ValueTask<ErrorOr<BookResponse>> Handle(AddBookCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -67,29 +67,29 @@ public class AddBookCommandHandler : IRequestHandler<AddBookCommand, ErrorOr<Boo
|
||||
Optional<BookRatingSource>.FromNullable(rating.Source.HasValue ? (BookRatingSource)(int)rating.Source : (BookRatingSource?)null),
|
||||
Optional<int>.FromNullable(rating.VoteCount)));
|
||||
// check if any of the results contain errors
|
||||
List<Error> errors = domainRatingsResult.Where(ratingResult => ratingResult.IsError).SelectMany(ratingResult => ratingResult.Errors).ToList();
|
||||
List<Error> errors = [.. domainRatingsResult.Where(ratingResult => ratingResult.IsError).SelectMany(ratingResult => ratingResult.Errors)];
|
||||
if (errors.Count != 0) // if there are errors, return them
|
||||
return errors;
|
||||
|
||||
List<BookRating> domainRatings = domainRatingsResult.Select(rating => rating.Value).ToList();
|
||||
List<BookRating> domainRatings = [.. domainRatingsResult.Select(rating => rating.Value)];
|
||||
|
||||
List<ErrorOr<Genre>> domainGenresResult = request.Metadata!.Genres!.ConvertAll(genre => Genre.Create(genre.Name!));
|
||||
errors = domainGenresResult.Where(genreResult => genreResult.IsError).SelectMany(genreResult => genreResult.Errors).ToList();
|
||||
errors = [.. domainGenresResult.Where(genreResult => genreResult.IsError).SelectMany(genreResult => genreResult.Errors)];
|
||||
if (errors.Count != 0)
|
||||
return errors;
|
||||
List<Genre> domainGenres = domainGenresResult.Select(genre => genre.Value).ToList();
|
||||
List<Genre> domainGenres = [.. domainGenresResult.Select(genre => genre.Value)];
|
||||
|
||||
List<ErrorOr<Tag>> domainTagsResult = request.Metadata.Tags!.ConvertAll(tag => Tag.Create(tag.Name!));
|
||||
errors = domainTagsResult.Where(tagResult => tagResult.IsError).SelectMany(tagResult => tagResult.Errors).ToList();
|
||||
errors = [.. domainTagsResult.Where(tagResult => tagResult.IsError).SelectMany(tagResult => tagResult.Errors)];
|
||||
if (errors.Count != 0)
|
||||
return errors;
|
||||
List<Tag> domainTags = domainTagsResult.Select(tag => tag.Value).ToList();
|
||||
List<Tag> domainTags = [.. domainTagsResult.Select(tag => tag.Value)];
|
||||
|
||||
List<ErrorOr<Isbn>> domainIsbnsResult = request.ISBNs!.ConvertAll(isbn => Isbn.Create(isbn.Value!, (IsbnFormat)(int)isbn.Format!));
|
||||
errors = domainIsbnsResult.Where(isbnResult => isbnResult.IsError).SelectMany(isbnResult => isbnResult.Errors).ToList();
|
||||
errors = [.. domainIsbnsResult.Where(isbnResult => isbnResult.IsError).SelectMany(isbnResult => isbnResult.Errors)];
|
||||
if (errors.Count != 0)
|
||||
return errors;
|
||||
List<Isbn> domainIsbns = domainIsbnsResult.Select(isbn => isbn.Value).ToList();
|
||||
List<Isbn> domainIsbns = [.. domainIsbnsResult.Select(isbn => isbn.Value)];
|
||||
|
||||
ErrorOr<ReleaseInfo> releaseInfoResult = ReleaseInfo.Create(
|
||||
Optional<DateOnly>.FromNullable(request.Metadata.ReleaseInfo!.OriginalReleaseDate),
|
||||
|
||||
Reference in new issue
Block a user