This commit is contained in:
@@ -1,21 +1,13 @@
|
||||
using NeDvachAPI.Models;
|
||||
using Npgsql;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace NeDvachAPI.DBControllers
|
||||
{
|
||||
public class DBchat
|
||||
{
|
||||
// Obtain connection string information from the portal
|
||||
|
||||
|
||||
public static List<Post> PostsList(string boardName, int thread)
|
||||
{
|
||||
// Build connection string using parameters from portal
|
||||
//Post[] posts = new Post[10];
|
||||
List<Post> posts = new List<Post>();
|
||||
//int postCount = 0;
|
||||
string received = "";
|
||||
string connString =
|
||||
string.Format(
|
||||
"Server={0}; User Id={1}; Database={2}; Port={3}; Password={4};SSLMode=Prefer",
|
||||
@@ -30,17 +22,6 @@ namespace NeDvachAPI.DBControllers
|
||||
|
||||
|
||||
conn.Open();
|
||||
|
||||
|
||||
// using ( var command = new NpgsqlCommand(@"
|
||||
// SELECT * FROM
|
||||
// (SELECT post_id, substring(post,1,200)
|
||||
// FROM dvach
|
||||
// ORDER BY post_id DESC
|
||||
// limit 10
|
||||
// )
|
||||
// subquery
|
||||
// ORDER BY post_id ASC", conn) )
|
||||
using (var command = new NpgsqlCommand($@"
|
||||
SELECT * FROM
|
||||
(
|
||||
@@ -55,13 +36,6 @@ namespace NeDvachAPI.DBControllers
|
||||
var reader = command.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
//received +=(
|
||||
//string.Format(
|
||||
//"#{0}: {1}" + "\n",
|
||||
// reader.GetInt32(0).ToString(),
|
||||
//reader.GetString(1)
|
||||
//)
|
||||
//);
|
||||
Post receivedPost = new()
|
||||
{
|
||||
Id = reader.GetInt32(0),
|
||||
@@ -71,8 +45,6 @@ namespace NeDvachAPI.DBControllers
|
||||
|
||||
};
|
||||
posts.Add(receivedPost);
|
||||
//posts[postCount] = receivedPost;
|
||||
//postCount++;
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
@@ -82,10 +54,7 @@ namespace NeDvachAPI.DBControllers
|
||||
|
||||
public static List<Post> ThreadsList(string boardName)
|
||||
{
|
||||
// Build connection string using parameters from portal
|
||||
//Post[] posts = new Post[10];
|
||||
List<Post> posts = new List<Post>();
|
||||
//int postCount = 0;
|
||||
string received = "";
|
||||
string connString =
|
||||
string.Format(
|
||||
@@ -102,16 +71,6 @@ namespace NeDvachAPI.DBControllers
|
||||
|
||||
conn.Open();
|
||||
|
||||
|
||||
// using ( var command = new NpgsqlCommand(@"
|
||||
// SELECT * FROM
|
||||
// (SELECT post_id, substring(post,1,200)
|
||||
// FROM dvach
|
||||
// ORDER BY post_id DESC
|
||||
// limit 10
|
||||
// )
|
||||
// subquery
|
||||
// ORDER BY post_id ASC", conn) )
|
||||
using (var command = new NpgsqlCommand($@"
|
||||
SELECT * FROM
|
||||
(
|
||||
@@ -127,13 +86,6 @@ namespace NeDvachAPI.DBControllers
|
||||
var reader = command.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
//received +=(
|
||||
//string.Format(
|
||||
//"#{0}: {1}" + "\n",
|
||||
// reader.GetInt32(0).ToString(),
|
||||
//reader.GetString(1)
|
||||
//)
|
||||
//);
|
||||
Post receivedPost = new()
|
||||
{
|
||||
Id = reader.GetInt32(0),
|
||||
@@ -145,8 +97,6 @@ namespace NeDvachAPI.DBControllers
|
||||
|
||||
};
|
||||
posts.Add(receivedPost);
|
||||
//posts[postCount] = receivedPost;
|
||||
//postCount++;
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
@@ -223,7 +173,6 @@ namespace NeDvachAPI.DBControllers
|
||||
command.Parameters.AddWithValue("postImgUrl", postToSend.ImgURL);
|
||||
command.Parameters.AddWithValue("threadId", postToSend.Thread_Id);
|
||||
command.Parameters.AddWithValue("ip", postToSend.Ip);
|
||||
//command.Parameters.AddWithValue("postTimeStamp", DateTime.Now.ToString("dd/MM/yyyy HH:mm"));
|
||||
int nRows = command.ExecuteNonQuery();
|
||||
Console.Out.WriteLine("Добавлен пост с текстом " + postToSend.Text + " номером " + 22);
|
||||
}
|
||||
@@ -244,7 +193,6 @@ namespace NeDvachAPI.DBControllers
|
||||
using (var conn = new NpgsqlConnection(connString))
|
||||
{
|
||||
|
||||
//Console.Out.WriteLine("Opening connection");
|
||||
conn.Open();
|
||||
|
||||
using (var command = new NpgsqlCommand(@"
|
||||
|
Reference in New Issue
Block a user