Added threads listing controller
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-11-24 12:56:07 +10:00
parent f8038d9587
commit f791625102
3 changed files with 99 additions and 2 deletions

View File

@@ -14,7 +14,7 @@ namespace NeDvachAPI.Controllers
public string Get([FromUri] string board, int thread)
{
string ipAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString();
List<Post> posts = DBchat.DbList(board, thread);
List<Post> posts = DBchat.PostsList(board, thread);
string postsJson = JsonSerializer.Serialize(posts);
Console.WriteLine("С адреса " + ipAddress + " запрошен список постов из борды " + board + " и треда# " + thread);
return postsJson ;

View File

@@ -0,0 +1,23 @@
using Microsoft.AspNetCore.Mvc;
using System.Text.Json;
using System.Web.Http;
using HttpGetAttribute = Microsoft.AspNetCore.Mvc.HttpGetAttribute;
using RouteAttribute = Microsoft.AspNetCore.Mvc.RouteAttribute;
namespace NeDvachAPI.Controllers
{
[ApiController]
[Route("[controller]")]
public class ThreadsController : ControllerBase
{
[HttpGet(Name = "GetThreads")]
public string Get([FromUri] string board)
{
string ipAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString();
List<Post> posts = DBchat.ThreadsList(board);
string postsJson = JsonSerializer.Serialize(posts);
Console.WriteLine("С адреса " + ipAddress + " запрошен список тредов из борды " + board);
return postsJson;
}
}
}