1 line
6.2 KiB
JSON
1 line
6.2 KiB
JSON
{"path":"NexusReader.Application/Queries/Library/GetMyEbooksQuery.cs","purpose":"MediatR query and handler that reads the current user's ebooks from the AppDbContext, projects them into LastReadBookDto instances, and returns them wrapped in a FluentResults Result.","classification":{"role":"handler","layer":"application","confidence":0.9,"evidence":["Command pattern","Implements MediatR IRequestHandler<GetMyEbooksQuery, Result<List<LastReadBookDto>>>","Uses IDbContextFactory<AppDbContext> to query Ebooks and project to DTOs"]},"className":"GetMyEbooksQueryHandler","methods":[{"name":"Handle","line":20,"endLine":45,"signature":"(request: GetMyEbooksQuery, cancellationToken: CancellationToken) -> Task<Result<List<LastReadBookDto>>>","purpose":"Opens a DbContext, queries ebooks for the given user id, projects results to LastReadBookDto list, and returns Result.Ok(list).","calls":[],"actions":[{"id":"resource-scope_22","kind":"mapping","label":"Create and scope DbContext","line":22,"detail":"using var dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken); (creates a scoped AppDbContext)","visibility":"detail-only","confidence":0.7},{"id":"handle_await_22_0","kind":"await","label":"Waits for async work","line":22,"detail":"using var dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);","visibility":"secondary-visible","confidence":0.81},{"id":"persistence-query_24","kind":"mapping","label":"Filter ebooks by user","line":24,"detail":"dbContext.Ebooks.Where(e => e.UserId == request.UserId) - applies filter by user id","visibility":"detail-only","confidence":0.7},{"id":"handle_await_24_1","kind":"await","label":"Waits for async work","line":24,"detail":"var ebooks = await dbContext.Ebooks","visibility":"secondary-visible","confidence":0.81},{"id":"handle_repository-read_25_2","kind":"repository-read","label":"Reads repository or persistence state","line":25,"detail":".Where(e => e.UserId == request.UserId)","visibility":"secondary-visible","confidence":0.86},{"id":"ordering_26","kind":"mapping","label":"Order by last read or added date desc","line":26,"detail":"OrderByDescending(e => e.LastReadDate ?? e.AddedDate)","visibility":"detail-only","confidence":0.7},{"id":"projection_27","kind":"mapping","label":"Map entity to LastReadBookDto","line":27,"detail":"Select(...) constructs LastReadBookDto and nested AuthorDto from entity fields (lines 27-41)","visibility":"detail-only","confidence":0.7},{"id":"handle_mapping_27_3","kind":"mapping","label":"Maps data or transforms shape","line":27,"detail":".Select(e => new LastReadBookDto","visibility":"detail-only","confidence":0.74},{"id":"external-call_42","kind":"external-call","label":"Execute query async","line":42,"detail":"ToListAsync(cancellationToken) - EF Core async materialization","visibility":"detail-only","confidence":0.7},{"id":"handle_return_44_4","kind":"return","label":"Returns result","line":44,"detail":"return Result.Ok(ebooks);","visibility":"detail-only","confidence":0.7},{"id":"return_44","kind":"return","label":"Wrap and return result","line":44,"detail":"return Result.Ok(ebooks);","visibility":"detail-only","confidence":0.7}]},{"name":"GetMyEbooksQueryHandler (ctor)","line":15,"endLine":18,"signature":"(dbContextFactory: IDbContextFactory<AppDbContext>) -> void","purpose":"Stores injected IDbContextFactory<AppDbContext> to a readonly field.","calls":[],"actions":[{"id":"assign_17","kind":"mapping","label":"Assign DI dependency","line":17,"detail":"_dbContextFactory = dbContextFactory","visibility":"detail-only","confidence":0.7}]}],"types":[{"name":"GetMyEbooksQuery","kind":"query","line":9,"purpose":"MediatR request holding the UserId for which ebooks should be fetched.","fields":[{"name":"UserId","type":"string","required":true,"line":9,"description":"Identifier of the user whose ebooks are requested"}]}],"serviceRegistrations":[],"startupActions":[],"dependencies":["NexusReader.Application.DTOs.User","NexusReader.Data.Persistence","FluentResults","MediatR","Microsoft.EntityFrameworkCore"],"patterns":["CQRS Handler","EF Core Query/Projection"],"domainConcepts":["Ebook","Author","User"],"keyDetails":"Performs a single DB query projecting entities to LastReadBookDto; uses IDbContextFactory for DbContext creation and returns a FluentResults Result wrapping the list.","orchestrationMethods":[{"name":"Handle","line":20,"confidence":0.69,"reason":"Contains 2 architectural actions relevant to business execution.","actionKinds":["mapping","await","repository-read","external-call","return"],"evidencePaths":["NexusReader.Application/Queries/Library/GetMyEbooksQuery.cs"]}],"typedContracts":[{"name":"GetMyEbooksQuery","kind":"query","line":9,"fieldCount":1,"evidencePaths":["NexusReader.Application/Queries/Library/GetMyEbooksQuery.cs"]}],"persistenceInteractions":[{"methodName":"Handle","line":25,"kind":"persistence-read","detail":".Where(e => e.UserId == request.UserId)","evidencePaths":["NexusReader.Application/Queries/Library/GetMyEbooksQuery.cs"]}],"externalInteractions":[{"methodName":"Handle","line":42,"kind":"external-call","detail":"ToListAsync(cancellationToken) - EF Core async materialization","evidencePaths":["NexusReader.Application/Queries/Library/GetMyEbooksQuery.cs"]}],"evidenceAnchors":[{"kind":"orchestration-method","label":"Handle","line":20,"summary":"Contains 2 architectural actions relevant to business execution.","confidence":0.69,"evidencePaths":["NexusReader.Application/Queries/Library/GetMyEbooksQuery.cs"]},{"kind":"typed-contract","label":"GetMyEbooksQuery","line":9,"summary":"query with 1 fields.","confidence":0.8,"evidencePaths":["NexusReader.Application/Queries/Library/GetMyEbooksQuery.cs"]},{"kind":"persistence","label":"Handle","line":25,"summary":".Where(e => e.UserId == request.UserId)","confidence":0.82,"evidencePaths":["NexusReader.Application/Queries/Library/GetMyEbooksQuery.cs"]},{"kind":"external-call","label":"Handle","line":42,"summary":"ToListAsync(cancellationToken) - EF Core async materialization","confidence":0.8,"evidencePaths":["NexusReader.Application/Queries/Library/GetMyEbooksQuery.cs"]}],"cacheMetadata":{"schemaVersion":2,"analysisVersion":"2026-05-23.cache-v1","contentChecksum":"cad3faef4b4f664ffcbe840c7f04cd63c9fbbb160d7d7d4ee0bd2fa00eb98b5c","sourceByteSize":1683,"analyzedAt":"2026-05-23T16:17:53.272Z","technology":"dotnet"}} |