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")]
|
||||
public string Get()
|
||||
{
|
||||
|
||||
//Post[] posts = DBchat.DbList();
|
||||
List<Post> posts = DBchat.DbList();
|
||||
string postsJson = JsonSerializer.Serialize(posts);
|
||||
Console.WriteLine("Запрошен список постов.");
|
||||
Console.WriteLine("Запрошен список постов.);
|
||||
return postsJson ;
|
||||
|
||||
|
||||
|
18
DBchat.cs
18
DBchat.cs
@ -65,10 +65,17 @@ namespace NeDvachAPI
|
||||
//);
|
||||
Post receivedPost = new()
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
Id = reader.GetInt32(0),
|
||||
Text = reader.GetString(1),
|
||||
Timestamp = reader.GetString(2),
|
||||
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[postCount] = receivedPost;
|
||||
@ -127,11 +134,16 @@ namespace NeDvachAPI
|
||||
conn.Open();
|
||||
|
||||
using (var command = new NpgsqlCommand(@"
|
||||
INSERT INTO dvach " + @"(post_id, post, post_timestamp)
|
||||
VALUES (DEFAULT, @postText, @postTimeStamp)", conn))
|
||||
INSERT INTO dvach (post_id, post, post_timestamp)
|
||||
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("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();
|
||||
Console.Out.WriteLine("Добавлен пост");
|
||||
|
Reference in New Issue
Block a user