finalizare 1.0

This commit is contained in:
andrei-mihnea-cerbu
2024-05-21 12:10:53 +03:00
parent f7795f7519
commit 1cc1d34003
11268 changed files with 2102399 additions and 10909 deletions
@@ -1,57 +1,58 @@
using Application.Endpoints;
using Application.Endpoints.Appointments;
using Application.Endpoints.Appointments.CreateAppointment;
using Application.Endpoints.Appointments.DeleteAppointment;
using Application.Endpoints.Appointments.QuerriesAppointments;
using Application.Services.Database.MongoDB;
using Application.Services.Database.PostgreSQL;
using Domain;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace API.Controllers;
[Route("api/[controller]")]
public class AppointmentsController : BaseApiController
public class AppointmentsController(
IAppointmentsMongoDbService appointmentsMongoDbService,
IPatientRepository patientRepository,
IDoctorRepository doctorRepository)
: 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;
}
[Authorize(Policy = Policies.ClientsOnlyPolicy)]
[HttpPost]
public async Task<ActionResult<BaseResponse>> CreateAppointment(AppointmentManagementDto dto)
public async Task<ActionResult<BaseResponse>> CreateAppointment(AppointmentInformation request,
CancellationToken token)
{
var handler =
new AppointmentManagementHandler(_appointmentsMongoDbService, _patientRepository, _doctorRepository);
var response = await handler.HandleCreateAppointment(dto).ConfigureAwait(false);
var handler = new CreateAppointmentHandler(appointmentsMongoDbService, patientRepository, doctorRepository);
var response = await handler.Handle(request, token);
return StatusCode(response.StatusCode, response);
}
[HttpDelete]
public async Task<ActionResult<BaseResponse>> DeleteAppointment(AppointmentManagementDto dto)
[Authorize(Policy = Policies.ClientsOnlyPolicy)]
[HttpPut]
public async Task<ActionResult<BaseResponse>> DeleteAppointment(AppointmentInformation request,
CancellationToken token)
{
var handler =
new AppointmentManagementHandler(_appointmentsMongoDbService, _patientRepository, _doctorRepository);
var response = await handler.HandleDeleteAppointment(dto).ConfigureAwait(false);
var handler = new DeleteAppointmentHandler(appointmentsMongoDbService, patientRepository, doctorRepository);
var response = await handler.Handle(request, token);
return StatusCode(response.StatusCode, response);
}
[Authorize(Policy = Policies.ClientsOnlyPolicy)]
[HttpGet("patient/{id:guid}")]
public async Task<ActionResult<BaseResponse>> GetAppointmentsByPatient(Guid id)
public async Task<ActionResult<BaseResponse>> GetAppointmentsByPatient(Guid id, CancellationToken token)
{
var handler = new AppointmentManagementHandler(_appointmentsMongoDbService, _patientRepository, _doctorRepository);
var response = await handler.HandleGetAppointmentsByPatientId(id);
var handler = new QuerriesAppointmentHandler(appointmentsMongoDbService);
var response = await handler.GetByPatientId(id, token);
return StatusCode(response.StatusCode, response);
}
[Authorize(Policy = Policies.ClientsOnlyPolicy)]
[HttpGet("doctor/{id:guid}")]
public async Task<ActionResult<BaseResponse>> GetAppointmentsByDoctor(Guid id)
public async Task<ActionResult<BaseResponse>> GetAppointmentsByDoctor(Guid id, CancellationToken token)
{
var handler = new AppointmentManagementHandler(_appointmentsMongoDbService, _patientRepository, _doctorRepository);
var response = await handler.HandleGetAppointmentsByDoctorId(id);
var handler = new QuerriesAppointmentHandler(appointmentsMongoDbService);
var response = await handler.GetsByDoctorId(id, token);
return StatusCode(response.StatusCode, response);
}
}