This repository has been archived on 2023-06-30. You can view files and clone it, but cannot push or open issues or pull requests.
2chBackAPI/APIControllers/PostPost.cs

35 lines
1.1 KiB
C#
Raw Normal View History

2022-10-17 14:29:09 +10:00
using Microsoft.AspNetCore.Mvc;
2022-11-25 22:40:17 +10:00
using NeDvachAPI.BufferControllers;
using NeDvachAPI.DBControllers;
using NeDvachAPI.Models;
2022-10-17 14:29:09 +10:00
namespace NeDvachAPI.Controllers
{
[ApiController]
[Route("[controller]")]
public class PostToController : ControllerBase
{
2022-10-18 01:25:59 +10:00
[HttpPost(Name = "PostPosts")]
2022-10-20 22:24:04 +10:00
public JsonResult ReceivePost([FromBody] Post ReceivedPost)
2022-10-17 14:29:09 +10:00
{
2022-11-22 18:03:38 +10:00
string ipAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString();
ReceivedPost.Ip = ipAddress;
2022-12-15 01:32:54 +10:00
if(ReceivedPost.Text.Length == 0)
{
return new JsonResult("Вы отправили пустое сообщение!");
}
2022-11-25 12:37:26 +10:00
try
{
DBchat.SendPost(ReceivedPost);
APIThreadBuffer.RefreshThread(ReceivedPost.Thread_Id);
return new JsonResult("Сообщение успешно добавлено.");
}
catch
{
return new JsonResult("Произошла ошибка постинга");
}
2022-10-17 14:29:09 +10:00
}
}
}