diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..862c268 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,35 @@ +{ + "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/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/bin/Debug/net6.0/NeDvachAPI.dll", + "args": [], + "cwd": "${workspaceFolder}", + "stopAtEntry": false, + // 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+)" + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceFolder}/Views" + } + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..9142f12 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,41 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/NeDvachAPI.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/NeDvachAPI.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "--project", + "${workspaceFolder}/NeDvachAPI.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/Controllers/TestPosting.cs b/Controllers/TestPosting.cs new file mode 100644 index 0000000..da917f4 --- /dev/null +++ b/Controllers/TestPosting.cs @@ -0,0 +1,17 @@ +using Microsoft.AspNetCore.Mvc; +using System.Text.Json; + +namespace NeDvachAPI.Controllers +{ + [ApiController] + [Route("[controller]")] + public class TestPostingController : ControllerBase + { + [HttpPost] + public int Area(int altitude , int height) + { + //DBchat.SendPost(ReceivedPost); + return altitude+height; + } + } +} diff --git a/DBchat.cs b/DBchat.cs index 7125fae..a9b5655 100644 --- a/DBchat.cs +++ b/DBchat.cs @@ -5,7 +5,6 @@ namespace NeDvachAPI public class DBchat { // Obtain connection string information from the portal - // private static string Host = "postgres.vdk2ch.ru"; private static string User = "postgres"; private static string DBname = "postgres"; @@ -34,7 +33,13 @@ namespace NeDvachAPI conn.Open(); - using (var command = new NpgsqlCommand("SELECT * FROM (SELECT post_id, substring(post,1,200) FROM dvach ORDER BY post_id DESC limit 10) subquery ORDER BY post_id ASC", conn)) + using (var command = new NpgsqlCommand(@" + SELECT * FROM + (SELECT post_id, substring(post,1,200) + FROM dvach + ORDER BY post_id + DESC limit 10) + subquery ORDER BY post_id ASC", conn)) { var reader = command.ExecuteReader(); @@ -113,8 +118,9 @@ namespace NeDvachAPI Console.Out.WriteLine("Opening connection"); conn.Open(); - using (var command = new NpgsqlCommand("INSERT INTO dvach " + - "(post_id, post) VALUES (DEFAULT, @postText)", conn)) + using (var command = new NpgsqlCommand(@" + INSERT INTO dvach " + @"(post_id, post) + VALUES (DEFAULT, @postText)", conn)) { command.Parameters.AddWithValue("postText", postToSend.Text); diff --git a/appsettings.Development.json b/appsettings.Development.json index 0c208ae..a6e86ac 100644 --- a/appsettings.Development.json +++ b/appsettings.Development.json @@ -1,7 +1,7 @@ { "Logging": { "LogLevel": { - "Default": "Information", + "Default": "Debug", "Microsoft.AspNetCore": "Warning" } } diff --git a/appsettings.json b/appsettings.json index 10f68b8..23039ed 100644 --- a/appsettings.json +++ b/appsettings.json @@ -1,7 +1,7 @@ { "Logging": { "LogLevel": { - "Default": "Information", + "Default": "Debug", "Microsoft.AspNetCore": "Warning" } },