diff --git a/sample/Ardalis.Sample.App3/Program.cs b/sample/Ardalis.Sample.App3/Program.cs index cfa88b28..eafb16f4 100644 --- a/sample/Ardalis.Sample.App3/Program.cs +++ b/sample/Ardalis.Sample.App3/Program.cs @@ -5,14 +5,15 @@ using AutoMapper; using Microsoft.EntityFrameworkCore; -// Sample Application 2 +// Sample Application 3 // The focus of this library are not the repositories. We're providing the built-in repository implementations just as a convenience. // You can certainly have your own repository implementations and tweak them per your needs. // In this sample we demonstrate how to do that, and some other more advanced features. // - Defined custom RepositoryBase implementation (also added an additional evaluator) // - Defined separate IRepository and IReadRepository interfaces. IRepository requires IAggregateRoot. // - Defined pagination constructs. -// - We're utilizing Automapper projections in our repository and defined ProjectTo methods for the IReadRepository. These methods return paginated response automatically. +// - We're utilizing Automapper projections in our repository and defined ProjectTo methods for the IReadRepository. +// These methods return paginated responses automatically. var builder = WebApplication.CreateBuilder(args); @@ -31,7 +32,9 @@ // Projecting directly to response DTOs. In addition the response is paginated and wrapped in PagedResponse. -app.MapGet("/customers", async (IReadRepository repo, [AsParameters] CustomerFilter filter, CancellationToken cancellationToken) => +app.MapGet("/customers", async (IReadRepository repo, + [AsParameters] CustomerFilter filter, + CancellationToken cancellationToken) => { var spec = new CustomerSpec(filter); var result = await repo.ProjectToListAsync(spec, filter, cancellationToken); @@ -39,7 +42,9 @@ }); // Projecting directly to response DTOs. -app.MapGet("/customers/{id}", async (IReadRepository repo, int id, CancellationToken cancellationToken) => +app.MapGet("/customers/{id}", async (IReadRepository repo, + int id, + CancellationToken cancellationToken) => { var spec = new CustomerByIdSpec(id); var result = await repo.ProjectToFirstOrDefaultAsync(spec, cancellationToken); @@ -47,7 +52,10 @@ return Results.Ok(result); }); -app.MapPost("/customers", async (IRepository repo, IMapper mapper, CustomerCreateDto customerCreateDto, CancellationToken cancellationToken) => +app.MapPost("/customers", async (IRepository repo, + IMapper mapper, + CustomerCreateDto customerCreateDto, + CancellationToken cancellationToken) => { var customer = new Customer { @@ -60,7 +68,11 @@ return Results.Ok(customerDto); }); -app.MapPut("/customers/{id}", async (IRepository repo, IMapper mapper, int id, CustomerUpdateDto customerUpdate, CancellationToken cancellationToken) => +app.MapPut("/customers/{id}", async (IRepository repo, + IMapper mapper, + int id, + CustomerUpdateDto customerUpdate, + CancellationToken cancellationToken) => { var spec = new CustomerByIdSpec(id); var customer = await repo.FirstOrDefaultAsync(spec, cancellationToken);