This commit is contained in:
2022-10-20 22:24:04 +10:00
parent 7dad7f6aae
commit 06d9835406
13 changed files with 89 additions and 6 deletions

19
Controllers/DeletePost.cs Normal file
View File

@@ -0,0 +1,19 @@
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!");
}
}
}

View File

@@ -12,8 +12,10 @@ namespace NeDvachAPI.Controllers
{
Post[] posts = DBchat.DbList();
string postsJson = JsonSerializer.Serialize(posts);
Console.WriteLine("Запрошен список постов.");
return postsJson ;
}
}
}

View File

@@ -8,9 +8,11 @@ namespace NeDvachAPI.Controllers
public class PostToController : ControllerBase
{
[HttpPost(Name = "PostPosts")]
public void ReceivePost([FromBody] Post ReceivedPost)
public JsonResult ReceivePost([FromBody] Post ReceivedPost)
{
Console.WriteLine("Принят пост");
DBchat.SendPost(ReceivedPost);
return new JsonResult("Posted Successfully!");
}
}
}

View File

@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using System.Net;
using System.Text.Json;
namespace NeDvachAPI.Controllers
@@ -8,10 +9,11 @@ namespace NeDvachAPI.Controllers
public class TestPostingController : ControllerBase
{
[HttpPost]
public int Area(int altitude , int height)
public int Area([FromForm] int height , int altitude)
{
//DBchat.SendPost(ReceivedPost);
return altitude+height;
Console.WriteLine("Received! " + height + " " + altitude );
return 200;
}
}
}