Compare commits
No commits in common. "2a71885a851f3a1c55ec46b82fe7b04c2d251c9b" and "0efca3b0b5781ab54d78c97a62b20b0f47d7dabf" have entirely different histories.
2a71885a85
...
0efca3b0b5
Binary file not shown.
Binary file not shown.
@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"ExpandedNodes": [
|
|
||||||
"",
|
|
||||||
"\\Controllers"
|
|
||||||
],
|
|
||||||
"SelectedNode": "\\Program.cs",
|
|
||||||
"PreviewInSolutionExplorer": false
|
|
||||||
}
|
|
BIN
.vs/slnx.sqlite
BIN
.vs/slnx.sqlite
Binary file not shown.
@ -1,19 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using System.Data;
|
|
||||||
using System.Text.Json;
|
|
||||||
|
|
||||||
namespace NeDvachAPI.Controllers
|
|
||||||
{
|
|
||||||
[ApiController]
|
|
||||||
[Route("[controller]")]
|
|
||||||
public class DeletePostController : ControllerBase
|
|
||||||
{
|
|
||||||
[HttpDelete("{id}")]
|
|
||||||
public JsonResult Get(string id)
|
|
||||||
{
|
|
||||||
DBchat.DeletePost(id);
|
|
||||||
return new JsonResult("Deleted Successfully!");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -13,10 +13,8 @@ namespace NeDvachAPI.Controllers
|
|||||||
//Post[] posts = DBchat.DbList();
|
//Post[] posts = DBchat.DbList();
|
||||||
List<Post> posts = DBchat.DbList();
|
List<Post> posts = DBchat.DbList();
|
||||||
string postsJson = JsonSerializer.Serialize(posts);
|
string postsJson = JsonSerializer.Serialize(posts);
|
||||||
Console.WriteLine("Запрошен список постов.");
|
|
||||||
return postsJson ;
|
return postsJson ;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,9 @@ namespace NeDvachAPI.Controllers
|
|||||||
public class PostToController : ControllerBase
|
public class PostToController : ControllerBase
|
||||||
{
|
{
|
||||||
[HttpPost(Name = "PostPosts")]
|
[HttpPost(Name = "PostPosts")]
|
||||||
public JsonResult ReceivePost([FromBody] Post ReceivedPost)
|
public void ReceivePost([FromBody] Post ReceivedPost)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Принят пост");
|
|
||||||
DBchat.SendPost(ReceivedPost);
|
DBchat.SendPost(ReceivedPost);
|
||||||
return new JsonResult("Posted Successfully!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System.Net;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace NeDvachAPI.Controllers
|
namespace NeDvachAPI.Controllers
|
||||||
@ -9,11 +8,10 @@ namespace NeDvachAPI.Controllers
|
|||||||
public class TestPostingController : ControllerBase
|
public class TestPostingController : ControllerBase
|
||||||
{
|
{
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public int Area([FromForm] int height , int altitude)
|
public int Area(int altitude , int height)
|
||||||
{
|
{
|
||||||
//DBchat.SendPost(ReceivedPost);
|
//DBchat.SendPost(ReceivedPost);
|
||||||
Console.WriteLine("Received! " + height + " " + altitude );
|
return altitude+height;
|
||||||
return 200;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
33
DBchat.cs
33
DBchat.cs
@ -1,5 +1,4 @@
|
|||||||
using Npgsql;
|
using Npgsql;
|
||||||
using static System.Net.Mime.MediaTypeNames;
|
|
||||||
|
|
||||||
namespace NeDvachAPI
|
namespace NeDvachAPI
|
||||||
{
|
{
|
||||||
@ -143,37 +142,5 @@ namespace NeDvachAPI
|
|||||||
|
|
||||||
Console.WriteLine("С добавлением закончено");
|
Console.WriteLine("С добавлением закончено");
|
||||||
}
|
}
|
||||||
public static void DeletePost(string idToDel) //удалялка
|
|
||||||
{
|
|
||||||
string connString =
|
|
||||||
String.Format(
|
|
||||||
"Server={0}; User Id={1}; Database={2}; Port={3}; Password={4};SSLMode=Prefer",
|
|
||||||
Host,
|
|
||||||
User,
|
|
||||||
DBname,
|
|
||||||
Port,
|
|
||||||
Password);
|
|
||||||
|
|
||||||
using (var conn = new NpgsqlConnection(connString))
|
|
||||||
{
|
|
||||||
|
|
||||||
//Console.Out.WriteLine("Opening connection");
|
|
||||||
conn.Open();
|
|
||||||
|
|
||||||
using (var command = new NpgsqlCommand(@"
|
|
||||||
DELETE FROM dvach
|
|
||||||
WHERE post_id = @ID", conn))
|
|
||||||
{
|
|
||||||
command.Parameters.AddWithValue("ID", int.Parse(idToDel)); ;
|
|
||||||
|
|
||||||
int nRows = command.ExecuteNonQuery();
|
|
||||||
Console.Out.WriteLine(String.Format("Number of rows updated={0}", nRows));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Console.WriteLine("Данные удалены!");
|
|
||||||
Console.ReadLine();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Controller_SelectedScaffolderID>MvcControllerWithActionsScaffolder</Controller_SelectedScaffolderID>
|
<Controller_SelectedScaffolderID>MvcControllerEmptyScaffolder</Controller_SelectedScaffolderID>
|
||||||
<Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath>
|
<Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
7
Post.cs
7
Post.cs
@ -8,11 +8,4 @@ namespace NeDvachAPI
|
|||||||
|
|
||||||
public string Text { get; set; }
|
public string Text { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ReceivedValues
|
|
||||||
{
|
|
||||||
public string height { get; set; }
|
|
||||||
|
|
||||||
public string altitude { get; set; }
|
|
||||||
}
|
|
||||||
}
|
}
|
12
Program.cs
12
Program.cs
@ -3,29 +3,19 @@ var builder = WebApplication.CreateBuilder(args);
|
|||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> 0efca3b0b5781ab54d78c97a62b20b0f47d7dabf
|
|
||||||
builder.Services.AddCors(setup =>
|
builder.Services.AddCors(setup =>
|
||||||
{
|
{
|
||||||
setup.AddDefaultPolicy(policyBuilder =>
|
setup.AddDefaultPolicy(policyBuilder =>
|
||||||
{
|
{
|
||||||
<<<<<<< HEAD
|
|
||||||
policyBuilder.WithOrigins("http://www.vdk2ch.ru:4200").WithMethods("PUT", "POST").WithHeaders("*");
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
=======
|
|
||||||
policyBuilder.WithOrigins("http://www.vdk2ch.ru:4200");
|
policyBuilder.WithOrigins("http://www.vdk2ch.ru:4200");
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
//builder.Services.AddSwaggerGen();
|
//builder.Services.AddSwaggerGen();
|
||||||
>>>>>>> 0efca3b0b5781ab54d78c97a62b20b0f47d7dabf
|
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user