31 lines
954 B
C#
31 lines
954 B
C#
using Microsoft.AspNetCore.Mvc;
|
|
using NeDvachAPI.BufferControllers;
|
|
using NeDvachAPI.DBControllers;
|
|
using NeDvachAPI.Models;
|
|
using System.Text.Json;
|
|
|
|
namespace NeDvachAPI.Controllers
|
|
{
|
|
[ApiController]
|
|
[Route("[controller]")]
|
|
public class PostToController : ControllerBase
|
|
{
|
|
[HttpPost(Name = "PostPosts")]
|
|
public JsonResult ReceivePost([FromBody] Post ReceivedPost)
|
|
{
|
|
string ipAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString();
|
|
ReceivedPost.Ip = ipAddress;
|
|
try
|
|
{
|
|
DBchat.SendPost(ReceivedPost);
|
|
APIThreadBuffer.RefreshThread(ReceivedPost.Thread_Id);
|
|
return new JsonResult("Сообщение успешно добавлено.");
|
|
}
|
|
catch
|
|
{
|
|
return new JsonResult("Произошла ошибка постинга");
|
|
}
|
|
}
|
|
}
|
|
}
|