From 8d297e52014f57fd44c9afd8a1a4c8ce31e9a6c9 Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Tue, 6 Feb 2024 12:37:38 -0500 Subject: [PATCH] formatting program.cs files in samples --- sample/Ardalis.Sample.App1/Program.cs | 20 ++++++++++++++++---- sample/Ardalis.Sample.App2/Program.cs | 24 +++++++++++++++++++----- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/sample/Ardalis.Sample.App1/Program.cs b/sample/Ardalis.Sample.App1/Program.cs index 71282e1b..45ab02de 100644 --- a/sample/Ardalis.Sample.App1/Program.cs +++ b/sample/Ardalis.Sample.App1/Program.cs @@ -28,7 +28,9 @@ app.UseHttpsRedirection(); -app.MapGet("/customers", async (IRepository repo, IMapper mapper, CancellationToken cancellationToken) => +app.MapGet("/customers", async (IRepository repo, + IMapper mapper, + CancellationToken cancellationToken) => { var spec = new CustomerSpec(); var customers = await repo.ListAsync(spec, cancellationToken); @@ -36,7 +38,10 @@ return Results.Ok(customersDto); }); -app.MapGet("/customers/{id}", async (IRepository repo, IMapper mapper, int id, CancellationToken cancellationToken) => +app.MapGet("/customers/{id}", async (IRepository repo, + IMapper mapper, + int id, + CancellationToken cancellationToken) => { var spec = new CustomerByIdSpec(id); var customer = await repo.FirstOrDefaultAsync(spec, cancellationToken); @@ -45,7 +50,10 @@ return Results.Ok(customerDto); }); -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 { @@ -58,7 +66,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); diff --git a/sample/Ardalis.Sample.App2/Program.cs b/sample/Ardalis.Sample.App2/Program.cs index d0234f5c..74c80218 100644 --- a/sample/Ardalis.Sample.App2/Program.cs +++ b/sample/Ardalis.Sample.App2/Program.cs @@ -30,7 +30,9 @@ app.UseHttpsRedirection(); -app.MapGet("/customers", async (IReadRepository repo, IMapper mapper, CancellationToken cancellationToken) => +app.MapGet("/customers", async (IReadRepository repo, + IMapper mapper, + CancellationToken cancellationToken) => { var spec = new CustomerSpec(); var customers = await repo.ListAsync(spec, cancellationToken); @@ -38,7 +40,10 @@ return Results.Ok(customersDto); }); -app.MapGet("/customers/{id}", async (IReadRepository repo, IMapper mapper, int id, CancellationToken cancellationToken) => +app.MapGet("/customers/{id}", async (IReadRepository repo, + IMapper mapper, + int id, + CancellationToken cancellationToken) => { var spec = new CustomerByIdSpec(id); // If you want to use the SingleOrDefault methods, the specification must inherit from SingleResultSpecification @@ -49,7 +54,10 @@ }); // Using the specification directly with the dbContext (no repositories). -app.MapGet("/customers/v2/{id}", async (AppDbContext dbContext, IMapper mapper, int id, CancellationToken cancellationToken) => +app.MapGet("/customers/v2/{id}", async (AppDbContext dbContext, + IMapper mapper, + int id, + CancellationToken cancellationToken) => { var spec = new CustomerByIdSpec(id); var customer = await dbContext.Customers @@ -61,7 +69,10 @@ }); // In this version, we're projecting the result to a DTO directly in the specification -app.MapGet("/customers/v3/{id}", async (IReadRepository repo, IMapper mapper, int id, CancellationToken cancellationToken) => +app.MapGet("/customers/v3/{id}", async (IReadRepository repo, + IMapper mapper, + int id, + CancellationToken cancellationToken) => { var spec = new CustomerByIdProjectionSpec(id); var customerDto = await repo.FirstOrDefaultAsync(spec, cancellationToken); @@ -70,7 +81,10 @@ }); // We're selecting only a name from Customer. -app.MapGet("/customer-names/{id}", async (IReadRepository repo, IMapper mapper, int id, CancellationToken cancellationToken) => +app.MapGet("/customer-names/{id}", async (IReadRepository repo, + IMapper mapper, + int id, + CancellationToken cancellationToken) => { var spec = new CustomerNameSpec(id); var name = await repo.FirstOrDefaultAsync(spec, cancellationToken);