added buffer and some error handling
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-11-25 12:37:26 +10:00
parent f791625102
commit 50a3c94af8
8 changed files with 81 additions and 28 deletions

View File

@@ -13,10 +13,7 @@ namespace NeDvachAPI.Controllers
[HttpGet(Name = "GetPosts")]
public string Get([FromUri] string board, int thread)
{
string ipAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString();
List<Post> posts = DBchat.PostsList(board, thread);
string postsJson = JsonSerializer.Serialize(posts);
Console.WriteLine("С адреса " + ipAddress + " запрошен список постов из борды " + board + " и треда# " + thread);
string postsJson = JsonSerializer.Serialize(APIThreadBuffer.GetThread(thread));
return postsJson ;
}
}

View File

@@ -12,8 +12,16 @@ namespace NeDvachAPI.Controllers
{
string ipAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString();
ReceivedPost.Ip = ipAddress;
DBchat.SendPost(ReceivedPost);
return new JsonResult("Posted Successfully!");
try
{
DBchat.SendPost(ReceivedPost);
APIThreadBuffer.RefreshThread(ReceivedPost.Thread_Id);
return new JsonResult("Сообщение успешно добавлено.");
}
catch
{
return new JsonResult("Произошла ошибка постинга");
}
}
}
}

View File

@@ -13,11 +13,8 @@ namespace NeDvachAPI.Controllers
[HttpGet(Name = "GetThreads")]
public string Get([FromUri] string board)
{
string ipAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString();
List<Post> posts = DBchat.ThreadsList(board);
string postsJson = JsonSerializer.Serialize(posts);
Console.WriteLine("С адреса " + ipAddress + " запрошен список тредов из борды " + board);
return postsJson;
string postsJson = JsonSerializer.Serialize(APIThreadBuffer.GetOPPosts());
return postsJson;
}
}
}