some scretches about file upload
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
RakVhalate 2022-11-02 01:46:58 +10:00
commit 3f580831a1
2 changed files with 18 additions and 5 deletions

View File

@ -9,11 +9,12 @@ 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 ;

View File

@ -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("Добавлен пост");