some scretches about file upload
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
commit
3f580831a1
@ -10,10 +10,11 @@ namespace NeDvachAPI.Controllers
|
|||||||
[HttpGet(Name = "GetPosts")]
|
[HttpGet(Name = "GetPosts")]
|
||||||
public string Get()
|
public string Get()
|
||||||
{
|
{
|
||||||
|
|
||||||
//Post[] posts = DBchat.DbList();
|
//Post[] posts = DBchat.DbList();
|
||||||
List<Post> posts = DBchat.DbList();
|
List<Post> posts = DBchat.DbList();
|
||||||
string postsJson = JsonSerializer.Serialize(posts);
|
string postsJson = JsonSerializer.Serialize(posts);
|
||||||
Console.WriteLine("Запрошен список постов.");
|
Console.WriteLine("Запрошен список постов.);
|
||||||
return postsJson ;
|
return postsJson ;
|
||||||
|
|
||||||
|
|
||||||
|
18
DBchat.cs
18
DBchat.cs
@ -65,10 +65,17 @@ namespace NeDvachAPI
|
|||||||
//);
|
//);
|
||||||
Post receivedPost = new()
|
Post receivedPost = new()
|
||||||
{
|
{
|
||||||
|
<<<<<<< HEAD
|
||||||
Id = reader.GetInt32(0),
|
Id = reader.GetInt32(0),
|
||||||
Text = reader.GetString(1),
|
Text = reader.GetString(1),
|
||||||
Timestamp = reader.GetString(2),
|
Timestamp = reader.GetString(2),
|
||||||
ImgURL = (string)reader.GetString(3)
|
ImgURL = (string)reader.GetString(3)
|
||||||
|
=======
|
||||||
|
//Date = DateTime.Now,
|
||||||
|
Id = reader.GetInt32(0),
|
||||||
|
Text = reader.GetString(1),
|
||||||
|
Timestamp = reader.GetString(2)
|
||||||
|
>>>>>>> 10b089091585b363d2cf227a688da611f5870b5d
|
||||||
};
|
};
|
||||||
posts.Add(receivedPost);
|
posts.Add(receivedPost);
|
||||||
//posts[postCount] = receivedPost;
|
//posts[postCount] = receivedPost;
|
||||||
@ -127,11 +134,16 @@ namespace NeDvachAPI
|
|||||||
conn.Open();
|
conn.Open();
|
||||||
|
|
||||||
using (var command = new NpgsqlCommand(@"
|
using (var command = new NpgsqlCommand(@"
|
||||||
INSERT INTO dvach " + @"(post_id, post, post_timestamp)
|
INSERT INTO dvach (post_id, post, post_timestamp)
|
||||||
VALUES (DEFAULT, @postText, @postTimeStamp)", conn))
|
VALUES ( DEFAULT, @postText, (
|
||||||
|
SELECT date_trunc(
|
||||||
|
'second',
|
||||||
|
(now()::timestamp(0) AT TIME ZONE 'UTC+10')::TIMESTAMP
|
||||||
|
)
|
||||||
|
) )", conn))
|
||||||
{
|
{
|
||||||
command.Parameters.AddWithValue("postText", postToSend.Text);
|
command.Parameters.AddWithValue("postText", postToSend.Text);
|
||||||
command.Parameters.AddWithValue("postTimeStamp", DateTime.Now.ToString("dd/MM/yyyy HH:mm"));
|
//command.Parameters.AddWithValue("postTimeStamp", DateTime.Now.ToString("dd/MM/yyyy HH:mm"));
|
||||||
|
|
||||||
int nRows = command.ExecuteNonQuery();
|
int nRows = command.ExecuteNonQuery();
|
||||||
Console.Out.WriteLine("Добавлен пост");
|
Console.Out.WriteLine("Добавлен пост");
|
||||||
|
Reference in New Issue
Block a user