This commit is contained in:
2022-10-17 14:29:09 +10:00
commit e3caf31f57
48 changed files with 1085 additions and 0 deletions

18
Controllers/GetPosts.cs Normal file
View File

@@ -0,0 +1,18 @@
using Microsoft.AspNetCore.Mvc;
using System.Text.Json;
namespace NeDvachAPI.Controllers
{
[ApiController]
[Route("[controller]")]
public class HomeController : ControllerBase
{
[HttpGet(Name = "GetPosts")]
public string Get()
{
Post[] posts = DBchat.DbList();
string postsJson = JsonSerializer.Serialize(posts);
return postsJson ;
}
}
}

17
Controllers/PostPost.cs Normal file
View File

@@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Mvc;
using System.Text.Json;
namespace NeDvachAPI.Controllers
{
[ApiController]
[Route("[controller]")]
public class PostToController : ControllerBase
{
[HttpGet(Name = "PostPosts")]
public void ReceivePost(string postJson)
{
Post ReceivedPost = JsonSerializer.Deserialize<Post>(postJson);
DBchat.SendPost(ReceivedPost);
}
}
}