diff --git a/Controllers/GetPosts.cs b/Controllers/GetPosts.cs index 8f2741c..b00a502 100644 --- a/Controllers/GetPosts.cs +++ b/Controllers/GetPosts.cs @@ -1,5 +1,8 @@ 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 { @@ -8,13 +11,13 @@ namespace NeDvachAPI.Controllers public class ListController : ControllerBase { [HttpGet(Name = "GetPosts")] - public string Get() + public string Get([FromUri] string board = null) { //Post[] posts = DBchat.DbList(); - List posts = DBchat.DbList(); + List posts = DBchat.DbList(board); string postsJson = JsonSerializer.Serialize(posts); - Console.WriteLine("Запрошен список постов"); + Console.WriteLine("Запрошен список постов из борды " + board); return postsJson ; diff --git a/DBchat.cs b/DBchat.cs index 4c55f4b..039663b 100644 --- a/DBchat.cs +++ b/DBchat.cs @@ -8,7 +8,7 @@ namespace NeDvachAPI // Obtain connection string information from the portal - public static List DbList() + public static List DbList(string boardName) { // Build connection string using parameters from portal //Post[] posts = new Post[10]; @@ -20,7 +20,7 @@ namespace NeDvachAPI "Server={0}; User Id={1}; Database={2}; Port={3}; Password={4};SSLMode=Prefer", AuthInfo.DB.Host, AuthInfo.DB.User, - AuthInfo.DB.DBname, + boardName, AuthInfo.DB.Port, AuthInfo.DB.Password); diff --git a/NeDvachAPI.csproj b/NeDvachAPI.csproj index 3c9a38b..5cad396 100644 --- a/NeDvachAPI.csproj +++ b/NeDvachAPI.csproj @@ -7,6 +7,7 @@ +