Manage Appointments DONE!

This commit is contained in:
andrei-mihnea-cerbu
2024-04-08 21:29:18 +03:00
parent 8663a186a0
commit 13bfa2bdd9
91 changed files with 762 additions and 52 deletions
@@ -0,0 +1,38 @@
using Application.Endpoints;
using Application.Endpoints.Appointments;
using Application.Services.Database;
using Application.Services.Database.MongoDB;
using Microsoft.AspNetCore.Mvc;
namespace API.Controllers;
public class AppointmentsController : BaseApiController
{
private readonly IAppointmentsMongoDbService _appointmentsMongoDbService;
private readonly IPatientRepository _patientRepository;
private readonly IDoctorRepository _doctorRepository;
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);
}
}
+26 -1
View File
@@ -4,6 +4,7 @@ using Application.Endpoints.Doctors.Profile;
using Application.Endpoints.Doctors.Registration;
using Application.Endpoints.Doctors.ResetPassword;
using Application.Services.Database;
using Application.Services.Database.MongoDB;
using Application.Services.HashingAlgorithms;
using Application.Services.Jwt;
using Core.Entities;
@@ -18,13 +19,15 @@ public class DoctorsController : ControllerBase
private readonly IDoctorRepository _database;
private readonly IHashingAlgorithms _hashingAlgorithms;
private readonly IJwtService _jwtService;
private readonly IAppointmentsMongoDbService _appointmentsMongoDbService;
public DoctorsController(IDoctorRepository database, IHashingAlgorithms hashingAlgorithms,
IJwtService jwtService)
IJwtService jwtService, IAppointmentsMongoDbService appointmentsMongoDbService)
{
_database = database;
_hashingAlgorithms = hashingAlgorithms;
_jwtService = jwtService;
_appointmentsMongoDbService = appointmentsMongoDbService;
}
[HttpPost("register")]
@@ -40,6 +43,7 @@ public class DoctorsController : ControllerBase
{
var handler = new DoctorLoginHandler(_database, _hashingAlgorithms);
var response = await handler.Handle(doctorLoginDto).ConfigureAwait(false);
/*
if (response.Data != null)
{
Doctor doctor = (Doctor)response.Data;
@@ -47,6 +51,7 @@ public class DoctorsController : ControllerBase
HttpContext.Response.Headers.Add("Authorization", $"Bearer {authToken}");
}
*/
return StatusCode(response.StatusCode, response);
}
@@ -125,6 +130,26 @@ public class DoctorsController : ControllerBase
{
var handler = new DoctorProfileHandler(_database, _hashingAlgorithms);
var response = await handler.HandleDelete(id).ConfigureAwait(false);
if (response.StatusCode < HttpStatusCodes.BadRequest)
{
DeleteDoctorAppointments(id);
}
return StatusCode(response.StatusCode, response);
}
private async void DeleteDoctorAppointments(Guid doctorId)
{
var criteria = new List<(string FieldName, string Value)>
{
("DoctorId", doctorId.ToString())
};
var appointments = await _appointmentsMongoDbService.FindAsync<Appointment>(criteria);
if (!appointments.Any())
{
return;
}
await _appointmentsMongoDbService.DeleteByIdAsync<Appointment>(appointments[0].Id);
}
}
@@ -48,6 +48,7 @@ public class PatientsController : ControllerBase
{
var handler = new PatientLoginHandler(_patientRepository);
var response = await handler.Handle(patientLoginDto).ConfigureAwait(false);
/*
if (response.Data != null)
{
Patient patient = (Patient)response.Data;
@@ -55,6 +56,7 @@ public class PatientsController : ControllerBase
HttpContext.Response.Headers.Add("Authorization", $"Bearer {authToken}");
}
*/
return StatusCode(response.StatusCode, response);
}
+12 -12
View File
@@ -53,18 +53,18 @@ if (app.Environment.IsDevelopment())
app.UseHttpsRedirection();
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuerSigningKey = true,
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(builder.Configuration["Jwt:SecretKey"])),
ValidateIssuer = false,
ValidateAudience = false,
ClockSkew = TimeSpan.Zero
};
});
//builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
// .AddJwtBearer(options =>
// {
// options.TokenValidationParameters = new TokenValidationParameters
// {
// ValidateIssuerSigningKey = true,
// IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(builder.Configuration["Jwt:SecretKey"])),
// ValidateIssuer = false,
// ValidateAudience = false,
// ClockSkew = TimeSpan.Zero
// };
// });
app.MapControllers();
+3 -2
View File
@@ -12,7 +12,8 @@
"HealthcareManagerDatabase": {
"Name": "HealthcareManager",
"MedicalRecordCollectionName": "MedicalHistory",
"ChatCollectionName": "Chat"
"ChatCollectionName": "Chat",
"AppointmentsCollectionName": "Appointments"
},
"ApiKeySettings": {
"ApiKey": "testapikey"
@@ -21,7 +22,7 @@
"SecretKey": "HealthcareManagerJwtKey",
"Issuer": "HealthcareManager",
"Audience": "HealthCareManagerUsers",
"ExpirationMinutes": 1440
"ExpirationTime": 1440
},
"AllowedHosts": "*"
}
+148 -1
View File
@@ -10,6 +10,7 @@
"dependencies": {
"Application": "1.0.0",
"Infrastructure": "1.0.0",
"Microsoft.AspNetCore.Authentication.JwtBearer": "8.0.3",
"Swashbuckle.AspNetCore": "6.5.0"
},
"runtime": {
@@ -54,6 +55,17 @@
}
}
},
"Microsoft.AspNetCore.Authentication.JwtBearer/8.0.3": {
"dependencies": {
"Microsoft.IdentityModel.Protocols.OpenIdConnect": "7.1.2"
},
"runtime": {
"lib/net8.0/Microsoft.AspNetCore.Authentication.JwtBearer.dll": {
"assemblyVersion": "8.0.3.0",
"fileVersion": "8.0.324.11615"
}
}
},
"Microsoft.EntityFrameworkCore/8.0.3": {
"dependencies": {
"Microsoft.EntityFrameworkCore.Abstractions": "8.0.3",
@@ -185,6 +197,71 @@
}
},
"Microsoft.Extensions.Primitives/8.0.0": {},
"Microsoft.IdentityModel.Abstractions/7.5.1": {
"runtime": {
"lib/net8.0/Microsoft.IdentityModel.Abstractions.dll": {
"assemblyVersion": "7.5.1.0",
"fileVersion": "7.5.1.50405"
}
}
},
"Microsoft.IdentityModel.JsonWebTokens/7.5.1": {
"dependencies": {
"Microsoft.IdentityModel.Tokens": "7.5.1"
},
"runtime": {
"lib/net8.0/Microsoft.IdentityModel.JsonWebTokens.dll": {
"assemblyVersion": "7.5.1.0",
"fileVersion": "7.5.1.50405"
}
}
},
"Microsoft.IdentityModel.Logging/7.5.1": {
"dependencies": {
"Microsoft.IdentityModel.Abstractions": "7.5.1"
},
"runtime": {
"lib/net8.0/Microsoft.IdentityModel.Logging.dll": {
"assemblyVersion": "7.5.1.0",
"fileVersion": "7.5.1.50405"
}
}
},
"Microsoft.IdentityModel.Protocols/7.1.2": {
"dependencies": {
"Microsoft.IdentityModel.Logging": "7.5.1",
"Microsoft.IdentityModel.Tokens": "7.5.1"
},
"runtime": {
"lib/net8.0/Microsoft.IdentityModel.Protocols.dll": {
"assemblyVersion": "7.1.2.0",
"fileVersion": "7.1.2.41121"
}
}
},
"Microsoft.IdentityModel.Protocols.OpenIdConnect/7.1.2": {
"dependencies": {
"Microsoft.IdentityModel.Protocols": "7.1.2",
"System.IdentityModel.Tokens.Jwt": "7.5.1"
},
"runtime": {
"lib/net8.0/Microsoft.IdentityModel.Protocols.OpenIdConnect.dll": {
"assemblyVersion": "7.1.2.0",
"fileVersion": "7.1.2.41121"
}
}
},
"Microsoft.IdentityModel.Tokens/7.5.1": {
"dependencies": {
"Microsoft.IdentityModel.Logging": "7.5.1"
},
"runtime": {
"lib/net8.0/Microsoft.IdentityModel.Tokens.dll": {
"assemblyVersion": "7.5.1.0",
"fileVersion": "7.5.1.50405"
}
}
},
"Microsoft.NETCore.Platforms/5.0.0": {},
"Microsoft.OpenApi/1.2.3": {
"runtime": {
@@ -350,6 +427,18 @@
}
},
"System.Buffers/4.5.1": {},
"System.IdentityModel.Tokens.Jwt/7.5.1": {
"dependencies": {
"Microsoft.IdentityModel.JsonWebTokens": "7.5.1",
"Microsoft.IdentityModel.Tokens": "7.5.1"
},
"runtime": {
"lib/net8.0/System.IdentityModel.Tokens.Jwt.dll": {
"assemblyVersion": "7.5.1.0",
"fileVersion": "7.5.1.50405"
}
}
},
"System.Memory/4.5.5": {},
"System.Runtime.CompilerServices.Unsafe/5.0.0": {},
"System.Security.AccessControl/5.0.0": {
@@ -400,8 +489,10 @@
"Microsoft.Extensions.Configuration": "8.0.0",
"Microsoft.Extensions.Configuration.Json": "8.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "8.0.0",
"Microsoft.IdentityModel.Tokens": "7.5.1",
"MongoDB.Driver": "2.24.0",
"Npgsql.EntityFrameworkCore.PostgreSQL": "8.0.2"
"Npgsql.EntityFrameworkCore.PostgreSQL": "8.0.2",
"System.IdentityModel.Tokens.Jwt": "7.5.1"
},
"runtime": {
"Infrastructure.dll": {}
@@ -443,6 +534,13 @@
"path": "fluentvalidation/11.9.0",
"hashPath": "fluentvalidation.11.9.0.nupkg.sha512"
},
"Microsoft.AspNetCore.Authentication.JwtBearer/8.0.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-VsDy8R6/0ushSpUow7m4lB82ovVBnI1e2AtPo1z22pzYzUjqY9QJvaexzqMkwmI3K1CVdT6MweXiWoqCcHrJbA==",
"path": "microsoft.aspnetcore.authentication.jwtbearer/8.0.3",
"hashPath": "microsoft.aspnetcore.authentication.jwtbearer.8.0.3.nupkg.sha512"
},
"Microsoft.EntityFrameworkCore/8.0.3": {
"type": "package",
"serviceable": true,
@@ -597,6 +695,48 @@
"path": "microsoft.extensions.primitives/8.0.0",
"hashPath": "microsoft.extensions.primitives.8.0.0.nupkg.sha512"
},
"Microsoft.IdentityModel.Abstractions/7.5.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-PT16ZFbPIiMsYv07oy3zOjqUOJ7xutGBkJTOX0+IbNyU6+O6X7aIxjq9EaSSRLWbekRgamgtmfg8Xjw6A6Ua9g==",
"path": "microsoft.identitymodel.abstractions/7.5.1",
"hashPath": "microsoft.identitymodel.abstractions.7.5.1.nupkg.sha512"
},
"Microsoft.IdentityModel.JsonWebTokens/7.5.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-93CGSa8RPdZU8zfvA3nf9NGKUqEnQrE12VzYlMqKh72ddhzusosqLNEUgH/YhFWBLRFOnY1RCgHMV7pR+sAx2w==",
"path": "microsoft.identitymodel.jsonwebtokens/7.5.1",
"hashPath": "microsoft.identitymodel.jsonwebtokens.7.5.1.nupkg.sha512"
},
"Microsoft.IdentityModel.Logging/7.5.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-PnpAQX20BAiDIPYmWUyQSlEaWD8BLXzHpiDGTCT568Cs0ReOeyzNe401LzCeiv6ilug/KefVeV1CeqtCHTo8dw==",
"path": "microsoft.identitymodel.logging/7.5.1",
"hashPath": "microsoft.identitymodel.logging.7.5.1.nupkg.sha512"
},
"Microsoft.IdentityModel.Protocols/7.1.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-SydLwMRFx6EHPWJ+N6+MVaoArN1Htt92b935O3RUWPY1yUF63zEjvd3lBu79eWdZUwedP8TN2I5V9T3nackvIQ==",
"path": "microsoft.identitymodel.protocols/7.1.2",
"hashPath": "microsoft.identitymodel.protocols.7.1.2.nupkg.sha512"
},
"Microsoft.IdentityModel.Protocols.OpenIdConnect/7.1.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-6lHQoLXhnMQ42mGrfDkzbIOR3rzKM1W1tgTeMPLgLCqwwGw0d96xFi/UiX/fYsu7d6cD5MJiL3+4HuI8VU+sVQ==",
"path": "microsoft.identitymodel.protocols.openidconnect/7.1.2",
"hashPath": "microsoft.identitymodel.protocols.openidconnect.7.1.2.nupkg.sha512"
},
"Microsoft.IdentityModel.Tokens/7.5.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-Q3DKpyFViP84IUlTFKH/zIkswIrmSh2Vd/eFDo4wlOHy4DYxoweZEEw4kDEiKt9VCX6o7SddK3HK2xDYyFpexA==",
"path": "microsoft.identitymodel.tokens/7.5.1",
"hashPath": "microsoft.identitymodel.tokens.7.5.1.nupkg.sha512"
},
"Microsoft.NETCore.Platforms/5.0.0": {
"type": "package",
"serviceable": true,
@@ -709,6 +849,13 @@
"path": "system.buffers/4.5.1",
"hashPath": "system.buffers.4.5.1.nupkg.sha512"
},
"System.IdentityModel.Tokens.Jwt/7.5.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-UUw+E0R73lZLlXgneYIJQxNs1kfbcxjVzw64JQyiwjqCd4HMpAbjn+xRo86QZT84uHq8/MkqvfH82tgjgPzpuw==",
"path": "system.identitymodel.tokens.jwt/7.5.1",
"hashPath": "system.identitymodel.tokens.jwt.7.5.1.nupkg.sha512"
},
"System.Memory/4.5.5": {
"type": "package",
"serviceable": true,
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -12,10 +12,17 @@
"HealthcareManagerDatabase": {
"Name": "HealthcareManager",
"MedicalRecordCollectionName": "MedicalHistory",
"ChatCollectionName": "Chat"
"ChatCollectionName": "Chat",
"AppointmentsCollectionName": "Appointments"
},
"ApiKeySettings": {
"ApiKey": "testapikey"
},
"Jwt": {
"SecretKey": "HealthcareManagerJwtKey",
"Issuer": "HealthcareManager",
"Audience": "HealthCareManagerUsers",
"ExpirationTime": 1440
},
"AllowedHosts": "*"
}
@@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("API")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+116405bd75830f3dec1c68562965bc78967039d5")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+8663a186a056b0dfbfeebf9ae16be42b40101093")]
[assembly: System.Reflection.AssemblyProductAttribute("API")]
[assembly: System.Reflection.AssemblyTitleAttribute("API")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
@@ -1 +1 @@
cef1c0cc4ccce44108fa880ecec8ba436aa9584f61400f2f44f2970c2d6842dc
a61f57beead854c5be97ca0cf9336ea23b19a3b596fd07a95a410574950b1887
@@ -1 +1 @@
06fc5bd1554959a9b32bbdb9ef6b3f86b090ac26bcc67914d438a39ee322e613
8e2d63c970dcfcf7fa32f83c388855a8383f3ed35cc314f5089a54d4a7d74fa6
@@ -56,3 +56,11 @@ C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\API\bin\Debug\net
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\API\bin\Debug\net8.0\FluentValidation.dll
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\API\bin\Debug\net8.0\Application.dll
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\API\bin\Debug\net8.0\Application.pdb
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\API\bin\Debug\net8.0\Microsoft.AspNetCore.Authentication.JwtBearer.dll
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\API\bin\Debug\net8.0\Microsoft.IdentityModel.Abstractions.dll
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\API\bin\Debug\net8.0\Microsoft.IdentityModel.JsonWebTokens.dll
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\API\bin\Debug\net8.0\Microsoft.IdentityModel.Logging.dll
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\API\bin\Debug\net8.0\Microsoft.IdentityModel.Protocols.dll
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\API\bin\Debug\net8.0\Microsoft.IdentityModel.Protocols.OpenIdConnect.dll
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\API\bin\Debug\net8.0\Microsoft.IdentityModel.Tokens.dll
C:\Users\Andrei Cerbu\Documents\FACULTATE\CC-FinalProj\backend\API\bin\Debug\net8.0\System.IdentityModel.Tokens.Jwt.dll
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
{"documents":{"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\*":"https://raw.githubusercontent.com/andrei-mihnea-cerbu/CC-FinalProj/48eb2adcbd149cd66c77ba558f492179d2bf29be/*"}}
{"documents":{"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\*":"https://raw.githubusercontent.com/andrei-mihnea-cerbu/CC-FinalProj/8663a186a056b0dfbfeebf9ae16be42b40101093/*"}}
Binary file not shown.
Binary file not shown.
Binary file not shown.