39 lines
1.5 KiB
C#
39 lines
1.5 KiB
C#
using Application.Endpoints;
|
|
using Application.Endpoints.Chats;
|
|
using Application.Services.Database.MongoDB;
|
|
using Application.Services.Database.PostgreSQL;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace API.Controllers;
|
|
|
|
[Route("api/[controller]")]
|
|
public class ChatController : BaseApiController
|
|
{
|
|
private readonly IChatMongoDbService _chatMongoDbService;
|
|
private readonly IDoctorRepository _doctorRepository;
|
|
private readonly IPatientRepository _patientRepository;
|
|
|
|
public ChatController(IChatMongoDbService chatMongoDbService, IPatientRepository patientRepository,
|
|
IDoctorRepository doctorRepository)
|
|
{
|
|
_chatMongoDbService = chatMongoDbService;
|
|
_patientRepository = patientRepository;
|
|
_doctorRepository = doctorRepository;
|
|
}
|
|
|
|
[HttpPost("send_message")]
|
|
public async Task<ActionResult<BaseResponse>> SendMessage(SendMessageDto sendMessageDto)
|
|
{
|
|
var handler = new ChatHandler(_chatMongoDbService, _patientRepository, _doctorRepository);
|
|
var response = await handler.HandleSendMessage(sendMessageDto).ConfigureAwait(false);
|
|
return StatusCode(response.StatusCode, response);
|
|
}
|
|
|
|
[HttpPost("get_conversation")]
|
|
public async Task<ActionResult<BaseResponse>> GetConversation(GetConversationDto getConversationDto)
|
|
{
|
|
var handler = new ChatHandler(_chatMongoDbService, _patientRepository, _doctorRepository);
|
|
var response = await handler.HandleGetConversation(getConversationDto).ConfigureAwait(false);
|
|
return StatusCode(response.StatusCode, response);
|
|
}
|
|
} |