diff --git a/.gitignore b/.gitignore index 015a401..8ee75b1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ **/obj **/bin **/appsettings.*.json -**/coverage*.xml \ No newline at end of file +**/coverage*.xml +.fake \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 8d9c612..d333f61 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,38 +1,18 @@ { + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { - // Use IntelliSense to find out which attributes exist for C# debugging - // Use hover for the description of the existing attributes - // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md - "name": ".NET Rest Api", - "type": "coreclr", + "type": "DotNetAutoAttach", "request": "launch", - "preLaunchTask": "build", - // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/MainProject/bin/Debug/net8.0/MainProject.dll", + "name": ".NET Core Watch: MainProject", "args": [], - "cwd": "${workspaceFolder}", - // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console - "console": "internalConsole", - "stopAtEntry": false, "env": { - "ASPNETCORE_ENVIRONMENT": "Development", - "ASPNETCORE_URLS": "https://localhost:5000;https://localhost:5001", - "ASPNETCORE_DETAILEDERRORS": "1", - "ASPNETCORE_SHUTDOWNTIMEOUTSECONDS": "3" + "ASPNETCORE_ENVIRONMENT": "Development" }, - // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser - "serverReadyAction": { - "action": "openExternally", - "pattern": "\\bNow listening on:\\s+(https?://\\S+)", - "uriFormat": "%s/swagger" - }, - }, - { - "name": ".NET Core Attach", - "type": "coreclr", - "request": "attach" + "project": "MainProject" } ] } \ No newline at end of file diff --git a/.vscode/launch.json_old b/.vscode/launch.json_old new file mode 100644 index 0000000..8d9c612 --- /dev/null +++ b/.vscode/launch.json_old @@ -0,0 +1,38 @@ +{ + "version": "0.2.0", + "configurations": [ + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md + "name": ".NET Rest Api", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/MainProject/bin/Debug/net8.0/MainProject.dll", + "args": [], + "cwd": "${workspaceFolder}", + // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console + "console": "internalConsole", + "stopAtEntry": false, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_URLS": "https://localhost:5000;https://localhost:5001", + "ASPNETCORE_DETAILEDERRORS": "1", + "ASPNETCORE_SHUTDOWNTIMEOUTSECONDS": "3" + }, + // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser + "serverReadyAction": { + "action": "openExternally", + "pattern": "\\bNow listening on:\\s+(https?://\\S+)", + "uriFormat": "%s/swagger" + }, + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index f7b90c3..2008219 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -7,7 +7,7 @@ "type": "process", "args": [ "build", - "${workspaceFolder}/MainProject/MainProject.csproj", + "${workspaceFolder}/BasicDotnetTemplate.sln", "/property:GenerateFullPaths=true", "/consoleloggerparameters:NoSummary;ForceNoAlign" ], @@ -19,7 +19,7 @@ "type": "process", "args": [ "publish", - "${workspaceFolder}/MainProject/MainProject.csproj", + "${workspaceFolder}/BasicDotnetTemplate.sln", "/property:GenerateFullPaths=true", "/consoleloggerparameters:NoSummary;ForceNoAlign" ], @@ -33,7 +33,7 @@ "watch", "run", "--project", - "${workspaceFolder}/MainProject.csproj" + "${workspaceFolder}/BasicDotnetTemplate.sln" ], "problemMatcher": "$msCompile" } diff --git a/MainProject/Controllers/BaseController.cs b/MainProject/Controllers/BaseController.cs index 0d3efa8..0bd4c27 100644 --- a/MainProject/Controllers/BaseController.cs +++ b/MainProject/Controllers/BaseController.cs @@ -27,26 +27,31 @@ namespace BasicDotnetTemplate.MainProject.Controllers protected new IActionResult Created(string message, object? data = null) { + message = String.IsNullOrEmpty(message) ? "Created" : message; return StatusCode((int)HttpStatusCode.Created, CreateResponse(HttpStatusCode.Created, message, data)); } protected IActionResult Success(string message, object? data = null) { + message = String.IsNullOrEmpty(message) ? "Success" : message; return StatusCode((int)HttpStatusCode.OK, CreateResponse(HttpStatusCode.OK, message, data)); } protected IActionResult NotFound(string message, object? data = null) { + message = String.IsNullOrEmpty(message) ? "Not found" : message; return StatusCode((int)HttpStatusCode.NotFound, CreateResponse(HttpStatusCode.NotFound, message, data)); } protected IActionResult BadRequest(string message, object? data = null) { + message = String.IsNullOrEmpty(message) ? "Bad request" : message; return StatusCode((int)HttpStatusCode.BadRequest, CreateResponse(HttpStatusCode.BadRequest, message, data)); } protected IActionResult InternalServerError(string message) { + message = String.IsNullOrEmpty(message) ? "Internal server error" : message; return StatusCode((int)HttpStatusCode.InternalServerError, CreateResponse(HttpStatusCode.InternalServerError, message)); }