chat controller

master
Tudor Stanciu 2020-06-06 23:49:05 +03:00
parent 235b6b52cc
commit 5a649681e9
2 changed files with 37 additions and 8 deletions

View File

@ -0,0 +1,36 @@
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);
}
}
}

View File

@ -32,18 +32,11 @@ namespace Chatbot.Api.Controllers
return Ok(result);
}
[HttpGet("initialize-session")]
[HttpGet("initialize-session/{botName}/{externalId}/{clientApplication}/{userKey}")]
public async Task<IActionResult> GetSession([FromRoute] GetSession.Query query)
{
var result = await _mediator.Send(query);
return Ok(result);
}
[HttpGet("initialize-chat")]
public async Task<IActionResult> GetChat([FromRoute] GetChat.Query query)
{
var result = await _mediator.Send(query);
return Ok(result);
}
}
}