added buffer and some error handling
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -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 ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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("Произошла ошибка постинга");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user