Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NET Core 3 Upgrade #430

Merged
merged 125 commits into from
Dec 1, 2019
Merged
Show file tree
Hide file tree
Changes from 107 commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
c7059b4
Revert "Roll back SDK"
Oct 16, 2019
d062360
Revert "Turn off HTML test logger"
Oct 16, 2019
84302b3
Upgrade to ASP.NET Core 3.0
Oct 16, 2019
80e00a8
Upgrade to ASP.NET Core 3.0
Oct 16, 2019
ef66039
Use RunAsync instead of Run
RehanSaeed Oct 17, 2019
601ccb3
Switch Orleans to use generic host builder
RehanSaeed Oct 17, 2019
5ac79dd
Add XForwardedFor,
RehanSaeed Oct 17, 2019
13f90a2
Use Async suffix
RehanSaeed Oct 17, 2019
fe2c253
Use Async suffix
RehanSaeed Oct 17, 2019
b4c6e24
Use generic host builder continued
RehanSaeed Oct 17, 2019
9ec625d
Use new host builder
RehanSaeed Oct 17, 2019
0dd2640
Use local references
RehanSaeed Oct 17, 2019
93a76e7
UpdateTraceIdentifier when passed an X-Correlation-ID HTTP header
Oct 18, 2019
3abc43b
Upgrade GraphQL to use host builder
Oct 18, 2019
64a5211
Upgrade to Swashbuckle 5
Oct 18, 2019
f41af28
.UseConsoleLifetime()
Oct 22, 2019
9d3296c
Upgrade host environment
Oct 22, 2019
e48a430
Add Microsoft.AspNetCore.Mvc.NewtonsoftJson
RehanSaeed Oct 22, 2019
b698b3c
Use Boxed.DotnetNewTest from project reference
RehanSaeed Oct 22, 2019
6883bc5
Remove compatibility version as it's a null op now
RehanSaeed Oct 22, 2019
fedfb5a
Use AddControllers
RehanSaeed Oct 22, 2019
2fc60c4
Add a comment about UseConsoleLifetime
Oct 23, 2019
f8b08eb
Remove comment
Oct 23, 2019
f42660e
Configure JSON options
Oct 23, 2019
b829b2a
Add JsonStringEnumConverter
Oct 23, 2019
da32d1e
Update formatters
Oct 23, 2019
9c5a918
Add AddKeyPerFile configuration provider
Oct 24, 2019
7311692
Bring back remove web.config
Oct 24, 2019
16cc5dd
Refactor UseDeveloperExceptionPage and use Newtonsoft in GraphQL
Oct 24, 2019
6fb0c97
Fix CORS
Oct 24, 2019
434a0a7
Add a TODO about UseCors
Oct 24, 2019
6da66ce
Add more comments
Oct 24, 2019
2f0c570
Register KestrelServerOptions
Oct 25, 2019
7139d2d
AllowSynchronousIO in GraphQL
Oct 25, 2019
3f40d71
Upgrade to Orleans 3.0.0
RehanSaeed Oct 26, 2019
41c71d2
Add UseSiloUnobservedExceptionsHandler
RehanSaeed Oct 26, 2019
ab0faba
Use fluent syntax
RehanSaeed Oct 27, 2019
f622064
Add TLS option to Orleans
RehanSaeed Oct 27, 2019
f5c196f
Fix warnings
RehanSaeed Oct 27, 2019
1fd80b7
Fix warnings
RehanSaeed Oct 27, 2019
2e56217
Fix warnings
RehanSaeed Oct 27, 2019
fb46b6f
Fix warnings
RehanSaeed Oct 27, 2019
130e239
Add Async suffix
RehanSaeed Oct 27, 2019
2c62a79
Add TODO
RehanSaeed Oct 27, 2019
6d69c67
Add Microsoft.ApplicationInsights.DependencyCollector
RehanSaeed Oct 27, 2019
16e5224
Add UseRouting and UseEndpoints
Oct 28, 2019
182ed6e
Remove blank line
Oct 28, 2019
bd5b964
Fix CORS
Oct 28, 2019
94f6f71
Static files has to come after CORS
Oct 28, 2019
d344372
Remove plain text output formatter
Oct 29, 2019
d261628
Add TLS
RehanSaeed Oct 30, 2019
4645d2f
Use IWebHostEnvironment instead of IHostEnvironment
RehanSaeed Oct 30, 2019
5a9e8c7
Switch from IHostEnvironment to IWebHostEnvironment
RehanSaeed Oct 30, 2019
f51db40
Fix UseSwagger
RehanSaeed Oct 30, 2019
0584645
Stop using StartupBase as it no longer works. See https://github.com/…
RehanSaeed Oct 30, 2019
08adae7
Fix operation filters
RehanSaeed Oct 30, 2019
c286787
Upgrade Versioning package
RehanSaeed Oct 30, 2019
aa0672c
Fix NuGet package
RehanSaeed Oct 31, 2019
461e002
Move AddVersionedApiExplorer to extension method
RehanSaeed Oct 31, 2019
061b92b
Fix app insights reference
RehanSaeed Oct 31, 2019
4d29187
Fix tests
RehanSaeed Oct 31, 2019
f8eea88
Add JsonPatchDocument deserialization support using Newtonsoft.Json
RehanSaeed Oct 31, 2019
d3340b0
Fix JSON patch tests
RehanSaeed Oct 31, 2019
2a4a7b8
Fix app insights
RehanSaeed Oct 31, 2019
09285f5
Remove Open API 'servers' section as I don't think it's needed
RehanSaeed Oct 31, 2019
3d78005
Update Open API filter
RehanSaeed Oct 31, 2019
284cb21
Use <example>foo</example> instead of schema filters
RehanSaeed Oct 31, 2019
a2a4512
Add names for OPTIONS routes
Nov 1, 2019
2f18592
Display the OperationId
Nov 1, 2019
0cb9aa0
Add more Swagger examples
RehanSaeed Nov 2, 2019
4cccf9f
Add blank line
RehanSaeed Nov 2, 2019
839cbda
Use constants
RehanSaeed Nov 2, 2019
7386b32
Fix controller name
RehanSaeed Nov 2, 2019
2dac3f0
Move URL's to remarks
RehanSaeed Nov 2, 2019
46a76e5
Remove non-existent folder
RehanSaeed Nov 2, 2019
435c246
Move correlation id operation filter to framework
RehanSaeed Nov 2, 2019
dcece5b
Add ClaimsOperationFilter
RehanSaeed Nov 2, 2019
e2d52ce
Remove text/xml media type
RehanSaeed Nov 2, 2019
151c2a1
Add ProblemDetailsSchemaFilter
RehanSaeed Nov 3, 2019
30a40be
Add ProblemDetails to error responses
RehanSaeed Nov 3, 2019
6513f09
Add application/problem+xml media type
RehanSaeed Nov 3, 2019
074601c
Remove ProblemDetails schema filter for now
RehanSaeed Nov 3, 2019
d1c0106
Update comment
RehanSaeed Nov 3, 2019
37fcc61
Test for ProblemDetails error response
RehanSaeed Nov 3, 2019
bc83900
Use PrivateAssets attribute
RehanSaeed Nov 3, 2019
f29a657
Rename variables
RehanSaeed Nov 3, 2019
e509d29
Update GraphQL WebApplicationFactory
RehanSaeed Nov 3, 2019
b2da794
AllowSynchronousIO for GraphQL tests
RehanSaeed Nov 3, 2019
bd7194e
Add IIS Express Production configuration
RehanSaeed Nov 3, 2019
b7c8e11
Add Watch Kestrel Production
RehanSaeed Nov 3, 2019
9ebf678
Add Development and Production startup configs
RehanSaeed Nov 3, 2019
074d93f
Add 415 and 406 tests
RehanSaeed Nov 3, 2019
a1b5c76
Remove word Development, takes too much space
RehanSaeed Nov 3, 2019
8fb55d4
Use synchronousIO when using IIS
RehanSaeed Nov 3, 2019
7abc456
Use is null instead of == null
RehanSaeed Nov 3, 2019
1c53dd1
Add 500 ProblemDetails response
Nov 7, 2019
43467a6
Update Microsoft.NET.Test.Sdk
Nov 7, 2019
c100e25
Add bug about 406 not returning ProblemDetails
Nov 7, 2019
ec84809
Add empty body request test
Nov 8, 2019
59c9213
UseSerilogRequestLogging
Nov 8, 2019
7dbff67
Use await to get rid of warnings
Nov 8, 2019
69e201b
UseCustomSerilogRequestLogging
Nov 8, 2019
18a382d
Include action name and id
Nov 8, 2019
8d18c3a
Add a comment
Nov 8, 2019
7810aa8
Git LFS
RehanSaeed Nov 10, 2019
8815733
Move IActionContextAccessor injection
RehanSaeed Nov 10, 2019
63016d7
Upgrade packages
Nov 11, 2019
bc0f3b6
Get IOptions from IConfiguration instead of BuildServiceProvider and …
RehanSaeed Nov 23, 2019
6fc6cd0
Minify images
RehanSaeed Nov 30, 2019
573fc78
Merge branch 'netcore3' of https://github.com/Dotnet-Boxed/Templates …
RehanSaeed Nov 30, 2019
3070cf1
Use NuGet packages
RehanSaeed Nov 30, 2019
4227d31
Fix warning and improve test
RehanSaeed Nov 30, 2019
01f3f0f
Use interface instead of concrete type
RehanSaeed Nov 30, 2019
c6a2938
Handle missing custom MIME types
RehanSaeed Nov 30, 2019
bef8e99
Update preview images
RehanSaeed Nov 30, 2019
17af2ce
Simplify #if's
RehanSaeed Nov 30, 2019
41b1de4
Use resolved type
RehanSaeed Nov 30, 2019
39a5de0
Fix file path too long error
RehanSaeed Nov 30, 2019
769cfd7
Conditional #if's require brackets
RehanSaeed Nov 30, 2019
ed53f88
Fix Versioning
RehanSaeed Dec 1, 2019
f23fdd8
Always clean up developer certificate in try finally
RehanSaeed Dec 1, 2019
06bd69b
Ignore Artefacts folder
RehanSaeed Dec 1, 2019
323994d
Upgrade packages
RehanSaeed Dec 1, 2019
16f124d
Use netstandard3.0
RehanSaeed Dec 1, 2019
1ffa5e2
Upgrade to .NET Core 3.0.101
RehanSaeed Dec 1, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Docs/Orleans.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ The [Microsoft Orleans](https://dotnet.github.io/orleans/) project template uses
- **ReadMe** - Add a README.md markdown file describing the project.
- **TreatWarningsAsErrors** - Treat warnings as errors.

#### Security

- **TLS** (Default=Off) - Adds TLS transport encryption to secure communication between the client and server.

#### Analytics

- **Analytics** - Monitor internal information about how your application is running, as well as external user information.
Expand Down
Binary file modified Images/API-Preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Images/API-Technology-Map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Images/Banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Images/GraphQL-Preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Images/GraphQL-Technology-Map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Images/GraphQL-Voyager-Preview.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions Images/Hero-1280x640.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Images/Hero-1366x768.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Images/Icon-128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Images/Icon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Images/Icon-256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Images/Icon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Images/Icon-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Images/Icon-64x64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Images/Orleans-Preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Images/Static-Files-Preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Images/Static-Files-Technology-Map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 2 additions & 3 deletions Source/ApiTemplate/.template.config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@
{
"condition": "(!Swagger)",
"exclude": [
"Source/ApiTemplate/OperationFilters/**/*",
"Source/ApiTemplate/ViewModelSchemaFilters/**/*"
"Source/ApiTemplate/OperationFilters/**/*"
]
},
// Versioning
Expand Down Expand Up @@ -491,4 +490,4 @@
]
}
]
}
}
32 changes: 15 additions & 17 deletions Source/ApiTemplate/Source/ApiTemplate/ApiTemplate.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<!--#if (AuthoringMode)-->
<PropertyGroup>
<!-- Modify these constants to enable/disable a feature to debug the template. Note that this only affects the C#. -->
Expand All @@ -13,8 +13,7 @@
<!--#endif-->

<PropertyGroup Label="Build">
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<TargetFramework>netcoreapp3.0</TargetFramework>
<!-- Use the latest version of the C# language. -->
<LangVersion>latest</LangVersion>
<!--#if (Swagger)-->
Expand All @@ -26,9 +25,6 @@
control provider. Only use this in Development, it is not intended for Production use.
See http://docs.asp.net/en/latest/security/app-secrets.html -->
<UserSecretsId>ApiTemplate-113f2d04-69f0-40c3-8797-ba3f356dd812</UserSecretsId>
<!-- Enable tiered JIT compilation for better performance.
See http://mattwarren.org/2017/12/15/How-does-.NET-JIT-a-method-and-Tiered-Compilation/ -->
<TieredCompilation>true</TieredCompilation>
<TreatWarningsAsErrors Condition="'$(TreatWarningsAsErrors)' == 'true'">true</TreatWarningsAsErrors>
<!--#if (!IIS)-->
<!-- Disable publishing of a web.config file for IIS when calling dotnet publish. -->
Expand All @@ -52,27 +48,29 @@
</ItemGroup>

<ItemGroup Label="Package References">
<PackageReference Include="Boxed.AspNetCore" Version="4.0.0" />
<ProjectReference Include="..\..\..\..\..\Framework\Source\Boxed.AspNetCore\Boxed.AspNetCore.csproj" />
<ProjectReference Include="..\..\..\..\..\Framework\Source\Boxed.AspNetCore.Swagger\Boxed.AspNetCore.Swagger.csproj" Condition="'$(Swagger)' == 'true'" />
<ProjectReference Include="..\..\..\..\..\Framework\Source\Boxed.Mapping\Boxed.Mapping.csproj" />
<!--<PackageReference Include="Boxed.AspNetCore" Version="4.0.0" />
<PackageReference Include="Boxed.AspNetCore.Swagger" Version="5.1.0" Condition="'$(Swagger)' == 'true'" />
<PackageReference Include="Boxed.Mapping" Version="2.0.0" />
<PackageReference Include="Boxed.Mapping" Version="2.0.0" />-->
<PackageReference Include="CorrelationId" Version="2.1.0" Condition="'$(CorrelationId)' == 'true'" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.8.2" Condition="'$(ApplicationInsights)' == 'true'" />
<PackageReference Include="Microsoft.AspNetCore.ApplicationInsights.HostingStartup" Version="2.2.0" Condition="'$(ApplicationInsights)' == 'true'" />
<PackageReference Include="Microsoft.AspNetCore.AzureAppServicesIntegration" Version="2.2.5" Condition="'$(Azure)' == 'true'" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="3.1.5" Condition="'$(Swagger)' == 'false' AND '$(Versioning)' == 'true'" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="3.2.1" Condition="'$(Swagger)' == 'true' AND '$(Versioning)' == 'true'" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.AzureAppServicesIntegration" Version="3.0.0" Condition="'$(Azure)' == 'true'" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="4.0.0" Condition="'$(Swagger)' == 'true' AND '$(Versioning)' == 'true'" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Serilog.AspNetCore" Version="3.2.0-dev-00135" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.3" />
<PackageReference Include="Serilog.Enrichers.Process" Version="2.0.1" />
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
<PackageReference Include="Serilog.Exceptions" Version="5.3.1" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.ApplicationInsights" Version="2.5.2" Condition="'$(ApplicationInsights)' == 'true'" />
<PackageReference Include="Serilog.Sinks.ApplicationInsights" Version="3.0.4" Condition="'$(ApplicationInsights)' == 'true'" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.Debug" Version="1.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" Condition="'$(Swagger)' == 'true'" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="4.0.1" Condition="'$(Swagger)' == 'true'" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc4" Condition="'$(Swagger)' == 'true'" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.0.0-rc4" Condition="'$(Swagger)' == 'true'" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,13 @@ namespace ApiTemplate
using Microsoft.AspNetCore.Builder;
#if Versioning
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.AspNetCore.Mvc.Infrastructure;
#endif
using Microsoft.Extensions.DependencyInjection;
using Serilog;

public static partial class ApplicationBuilderExtensions
{
/// <summary>
/// Adds developer friendly error pages for the application which contain extra debug and exception information.
/// Note: It is unsafe to use this in production.
/// </summary>
public static IApplicationBuilder UseDeveloperErrorPages(this IApplicationBuilder application) =>
application
// When a database error occurs, displays a detailed error page with full diagnostic information. It is
// unsafe to use this in production. Uncomment this if using a database.
// .UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll);
// When an error occurs, displays a detailed error page with full diagnostic information.
// See http://docs.asp.net/en/latest/fundamentals/diagnostics.html
.UseDeveloperExceptionPage();

/// <summary>
/// Uses the static files middleware to serve static files. Also adds the Cache-Control and Pragma HTTP
/// headers. The cache duration is controlled from configuration.
Expand All @@ -50,6 +39,23 @@ public static IApplicationBuilder UseStaticFilesWithCacheControl(this IApplicati
});
}

/// <summary>
/// Uses custom serilog request logging. Adds additional properties to each log.
/// See https://github.com/serilog/serilog-aspnetcore.
/// </summary>
public static IApplicationBuilder UseCustomSerilogRequestLogging(
this IApplicationBuilder application,
IActionContextAccessor actionContextAccessor) =>
application.UseSerilogRequestLogging(
options => options.EnrichDiagnosticContext = (diagnosticContext, httpContext) =>
{
var actionDescriptor = actionContextAccessor.ActionContext.ActionDescriptor;
RehanSaeed marked this conversation as resolved.
Show resolved Hide resolved
diagnosticContext.Set("ActionName", actionDescriptor.DisplayName);
diagnosticContext.Set("ActionId", actionDescriptor.Id);
diagnosticContext.Set("RequestHost", httpContext.Request.Host.Value);
diagnosticContext.Set("RequestScheme", httpContext.Request.Scheme);
});

#if Swagger

public static IApplicationBuilder UseCustomSwaggerUI(this IApplicationBuilder application) =>
Expand All @@ -63,7 +69,8 @@ public static IApplicationBuilder UseCustomSwaggerUI(this IApplicationBuilder ap
.Product;
// Set the Swagger UI to render at '/'.
options.RoutePrefix = string.Empty;
// Show the request duration in Swagger UI.

options.DisplayOperationId();
options.DisplayRequestDuration();

#if Versioning
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ public DeleteCarCommand(ICarRepository carRepository) =>

public async Task<IActionResult> ExecuteAsync(int carId, CancellationToken cancellationToken)
{
var car = await this.carRepository.Get(carId, cancellationToken);
if (car == null)
var car = await this.carRepository.GetAsync(carId, cancellationToken);
if (car is null)
{
return new NotFoundResult();
}

await this.carRepository.Delete(car, cancellationToken);
await this.carRepository.DeleteAsync(car, cancellationToken);

return new NoContentResult();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace ApiTemplate.Commands
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.Extensions.Primitives;
using Microsoft.Net.Http.Headers;

public class GetCarCommand : IGetCarCommand
Expand All @@ -30,8 +29,8 @@ public GetCarCommand(

public async Task<IActionResult> ExecuteAsync(int carId, CancellationToken cancellationToken)
{
var car = await this.carRepository.Get(carId, cancellationToken);
if (car == null)
var car = await this.carRepository.GetAsync(carId, cancellationToken);
if (car is null)
{
return new NotFoundResult();
}
Expand Down
32 changes: 16 additions & 16 deletions Source/ApiTemplate/Source/ApiTemplate/Commands/GetCarPageCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ public async Task<IActionResult> ExecuteAsync(PageOptions pageOptions, Cancellat
var createdAfter = Cursor.FromCursor<DateTimeOffset?>(pageOptions.After);
var createdBefore = Cursor.FromCursor<DateTimeOffset?>(pageOptions.Before);

var getCarsTask = this.GetCars(pageOptions.First, pageOptions.Last, createdAfter, createdBefore, cancellationToken);
var getHasNextPageTask = this.GetHasNextPage(pageOptions.First, createdAfter, createdBefore, cancellationToken);
var getHasPreviousPageTask = this.GetHasPreviousPage(pageOptions.Last, createdAfter, createdBefore, cancellationToken);
var totalCountTask = this.carRepository.GetTotalCount(cancellationToken);
var getCarsTask = this.GetCarsAsync(pageOptions.First, pageOptions.Last, createdAfter, createdBefore, cancellationToken);
var getHasNextPageTask = this.GetHasNextPageAsync(pageOptions.First, createdAfter, createdBefore, cancellationToken);
var getHasPreviousPageTask = this.GetHasPreviousPageAsync(pageOptions.Last, createdAfter, createdBefore, cancellationToken);
var totalCountTask = this.carRepository.GetTotalCountAsync(cancellationToken);

await Task.WhenAll(getCarsTask, getHasNextPageTask, getHasPreviousPageTask, totalCountTask);
var cars = getCarsTask.Result;
var hasNextPage = getHasNextPageTask.Result;
var hasPreviousPage = getHasPreviousPageTask.Result;
var totalCount = totalCountTask.Result;
var cars = await getCarsTask;
var hasNextPage = await getHasNextPageTask;
var hasPreviousPage = await getHasPreviousPageTask;
var totalCount = await totalCountTask;

if (cars == null)
if (cars is null)
{
return new NotFoundResult();
}
Expand Down Expand Up @@ -110,7 +110,7 @@ public async Task<IActionResult> ExecuteAsync(PageOptions pageOptions, Cancellat
return new OkObjectResult(connection);
}

private Task<List<Models.Car>> GetCars(
private Task<List<Models.Car>> GetCarsAsync(
int? first,
int? last,
DateTimeOffset? createdAfter,
Expand All @@ -120,25 +120,25 @@ public async Task<IActionResult> ExecuteAsync(PageOptions pageOptions, Cancellat
Task<List<Models.Car>> getCarsTask;
if (first.HasValue)
{
getCarsTask = this.carRepository.GetCars(first, createdAfter, createdBefore, cancellationToken);
getCarsTask = this.carRepository.GetCarsAsync(first, createdAfter, createdBefore, cancellationToken);
}
else
{
getCarsTask = this.carRepository.GetCarsReverse(last, createdAfter, createdBefore, cancellationToken);
getCarsTask = this.carRepository.GetCarsReverseAsync(last, createdAfter, createdBefore, cancellationToken);
}

return getCarsTask;
}

private async Task<bool> GetHasNextPage(
private async Task<bool> GetHasNextPageAsync(
int? first,
DateTimeOffset? createdAfter,
DateTimeOffset? createdBefore,
CancellationToken cancellationToken)
{
if (first.HasValue)
{
return await this.carRepository.GetHasNextPage(first, createdAfter, cancellationToken);
return await this.carRepository.GetHasNextPageAsync(first, createdAfter, cancellationToken);
}
else if (createdBefore.HasValue)
{
Expand All @@ -148,15 +148,15 @@ private async Task<bool> GetHasNextPage(
return false;
}

private async Task<bool> GetHasPreviousPage(
private async Task<bool> GetHasPreviousPageAsync(
int? last,
DateTimeOffset? createdAfter,
DateTimeOffset? createdBefore,
CancellationToken cancellationToken)
{
if (last.HasValue)
{
return await this.carRepository.GetHasPreviousPage(last, createdBefore, cancellationToken);
return await this.carRepository.GetHasPreviousPageAsync(last, createdBefore, cancellationToken);
}
else if (createdAfter.HasValue)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public async Task<IActionResult> ExecuteAsync(
JsonPatchDocument<SaveCar> patch,
CancellationToken cancellationToken)
{
var car = await this.carRepository.Get(carId, cancellationToken);
if (car == null)
var car = await this.carRepository.GetAsync(carId, cancellationToken);
if (car is null)
{
return new NotFoundResult();
}
Expand All @@ -60,10 +60,10 @@ public async Task<IActionResult> ExecuteAsync(
}

this.saveCarToCarMapper.Map(saveCar, car);
await this.carRepository.Update(car, cancellationToken);
await this.carRepository.UpdateAsync(car, cancellationToken);
var carViewModel = this.carToCarMapper.Map(car);

return new OkObjectResult(carViewModel);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public PostCarCommand(
public async Task<IActionResult> ExecuteAsync(SaveCar saveCar, CancellationToken cancellationToken)
{
var car = this.saveCarToCarMapper.Map(saveCar);
car = await this.carRepository.Add(car, cancellationToken);
car = await this.carRepository.AddAsync(car, cancellationToken);
var carViewModel = this.carToCarMapper.Map(car);

return new CreatedAtRouteResult(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ public PutCarCommand(

public async Task<IActionResult> ExecuteAsync(int carId, SaveCar saveCar, CancellationToken cancellationToken)
{
var car = await this.carRepository.Get(carId, cancellationToken);
if (car == null)
var car = await this.carRepository.GetAsync(carId, cancellationToken);
if (car is null)
{
return new NotFoundResult();
}

this.saveCarToCarMapper.Map(saveCar, car);
car = await this.carRepository.Update(car, cancellationToken);
car = await this.carRepository.UpdateAsync(car, cancellationToken);
var carViewModel = this.carToCarMapper.Map(car);

return new OkObjectResult(carViewModel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ namespace ApiTemplate.Constants
{
public static class CarsControllerRoute
{
public const string DeleteCar = ControllerName.Car + nameof(DeleteCar);
public const string GetCar = ControllerName.Car + nameof(GetCar);
public const string GetCarPage = ControllerName.Car + nameof(GetCarPage);
public const string HeadCar = ControllerName.Car + nameof(HeadCar);
public const string HeadCarPage = ControllerName.Car + nameof(HeadCarPage);
public const string PatchCar = ControllerName.Car + nameof(PatchCar);
public const string PostCar = ControllerName.Car + nameof(PostCar);
public const string PutCar = ControllerName.Car + nameof(PutCar);
public const string DeleteCar = ControllerName.Cars + nameof(DeleteCar);
public const string GetCar = ControllerName.Cars + nameof(GetCar);
public const string GetCarPage = ControllerName.Cars + nameof(GetCarPage);
public const string HeadCar = ControllerName.Cars + nameof(HeadCar);
public const string HeadCarPage = ControllerName.Cars + nameof(HeadCarPage);
public const string OptionsCar = ControllerName.Cars + nameof(OptionsCar);
public const string OptionsCars = ControllerName.Cars + nameof(OptionsCars);
public const string PatchCar = ControllerName.Cars + nameof(PatchCar);
public const string PostCar = ControllerName.Cars + nameof(PostCar);
public const string PutCar = ControllerName.Cars + nameof(PutCar);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ namespace ApiTemplate.Constants
{
public static class ControllerName
{
public const string Car = nameof(Car);
public const string Cars = nameof(Cars);
}
}
}
Loading