37 lines
1.4 KiB
C#
37 lines
1.4 KiB
C#
using Application.Endpoints;
|
|
using Application.Endpoints.Chats;
|
|
using Application.Endpoints.Chats.GetChats;
|
|
using Application.Endpoints.Chats.SendMessage;
|
|
using Application.Services.Database.MongoDB;
|
|
using Application.Services.Database.PostgreSQL;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace API.Controllers;
|
|
|
|
[Route("api/[controller]")]
|
|
public class ChatController(
|
|
IChatMongoDbService chatMongoDbService,
|
|
IPatientRepository patientRepository,
|
|
IDoctorRepository doctorRepository)
|
|
: BaseApiController
|
|
{
|
|
[Authorize(Policy = Policies.ClientsOnlyPolicy)]
|
|
[HttpPost("send_message")]
|
|
public async Task<ActionResult<BaseResponse>> SendMessage(SendMessageCommand request, CancellationToken token)
|
|
{
|
|
var handler = new SendMessageHandler(chatMongoDbService, patientRepository, doctorRepository);
|
|
var response = await handler.Handle(request, token);
|
|
return StatusCode(response.StatusCode, response);
|
|
}
|
|
|
|
[Authorize(Policy = Policies.ClientsOnlyPolicy)]
|
|
[HttpPost("get_conversation")]
|
|
public async Task<ActionResult<BaseResponse>> GetConversation(
|
|
GetConversationsCommand request, CancellationToken token)
|
|
{
|
|
var handler = new GetConversationsHandler(chatMongoDbService, patientRepository, doctorRepository);
|
|
var response = await handler.HandleGetConversation(request, token);
|
|
return StatusCode(response.StatusCode, response);
|
|
}
|
|
} |