41 lines
1.6 KiB
C#
41 lines
1.6 KiB
C#
using Application.Endpoints;
|
|
using Application.Endpoints.Appointments;
|
|
using Application.Services.Database.MongoDB;
|
|
using Application.Services.Database.PostgreSQL;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace API.Controllers;
|
|
|
|
[Route("api/[controller]")]
|
|
public class AppointmentsController : BaseApiController
|
|
{
|
|
private readonly IAppointmentsMongoDbService _appointmentsMongoDbService;
|
|
private readonly IDoctorRepository _doctorRepository;
|
|
private readonly IPatientRepository _patientRepository;
|
|
|
|
public AppointmentsController(IAppointmentsMongoDbService appointmentsMongoDbService,
|
|
IPatientRepository patientRepository, IDoctorRepository doctorRepository)
|
|
{
|
|
_appointmentsMongoDbService = appointmentsMongoDbService;
|
|
_patientRepository = patientRepository;
|
|
_doctorRepository = doctorRepository;
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<ActionResult<BaseResponse>> CreateAppointment(AppointmentManagementDto dto)
|
|
{
|
|
var handler =
|
|
new AppointmentManagementHandler(_appointmentsMongoDbService, _patientRepository, _doctorRepository);
|
|
var response = await handler.HandleCreateAppointment(dto).ConfigureAwait(false);
|
|
return StatusCode(response.StatusCode, response);
|
|
}
|
|
|
|
[HttpDelete]
|
|
public async Task<ActionResult<BaseResponse>> DeleteAppointment(AppointmentManagementDto dto)
|
|
{
|
|
var handler =
|
|
new AppointmentManagementHandler(_appointmentsMongoDbService, _patientRepository, _doctorRepository);
|
|
var response = await handler.HandleDeleteAppointment(dto).ConfigureAwait(false);
|
|
return StatusCode(response.StatusCode, response);
|
|
}
|
|
} |