chatbot/Chatbot.Api/Controllers/ChatController.cs

44 lines
1.2 KiB
C#
Raw Permalink Normal View History

2020-06-06 23:49:05 +03:00
using Chatbot.Api.Application.Commands;
using Chatbot.Api.Application.Queries;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
namespace Chatbot.Api.Controllers
{
[Authorize]
[ApiController]
[Route("chat")]
public class ChatController : ControllerBase
{
private readonly IMediator _mediator;
public ChatController(IMediator mediator)
{
_mediator = mediator;
}
[HttpGet("initialize/{sessionId}")]
public async Task<IActionResult> GetChat([FromRoute] GetChat.Query query)
{
var result = await _mediator.Send(query);
return Ok(result);
}
[HttpPost("message")]
public async Task<IActionResult> SaveChatMessage([FromBody] SaveChatMessage saveChatMessage)
{
var result = await _mediator.Send(saveChatMessage);
return Ok(result);
}
2020-06-07 02:38:52 +03:00
[HttpPost("close")]
public async Task<IActionResult> CloseChat([FromBody] CloseChat closeChat)
{
var result = await _mediator.Send(closeChat);
return Ok(result);
}
2020-06-06 23:49:05 +03:00
}
}