37 lines
987 B
C#
37 lines
987 B
C#
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);
|
|
}
|
|
}
|
|
}
|