Manage Appointments DONE!
This commit is contained in:
@@ -18,7 +18,7 @@ public class JwtService : IJwtService
|
||||
_secretKey = configuration["Jwt:SecretKey"];
|
||||
_issuer = configuration["Jwt:Issuer"];
|
||||
_audience = configuration["Jwt:Audience"];
|
||||
_expiryMinutes = double.Parse(configuration["Jwt:ExpiryMinutes"]);
|
||||
_expiryMinutes = double.Parse(configuration["Jwt:ExpirationTime"]);
|
||||
}
|
||||
|
||||
public string GenerateJwtToken(string email)
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
using Application.Endpoints.Appointments;
|
||||
using Application.Services.Database.MongoDB;
|
||||
using Core.Entities;
|
||||
|
||||
namespace Infrastructure.Services.MongoDB;
|
||||
|
||||
public class AppointmentsMongoDbService : MongoDbService, IAppointmentsMongoDbService
|
||||
{
|
||||
public AppointmentsMongoDbService(string connectionString, string databaseName, string collectionName)
|
||||
: base(connectionString, databaseName, collectionName)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<bool> IsAppointmentUnique(AppointmentManagementDto dto)
|
||||
{
|
||||
var appointment = dto.Appointment.ToUniversalTime();
|
||||
|
||||
var criteria = new List<(string FieldName, string Value)>
|
||||
{
|
||||
("DoctorId", dto.DoctorId.ToString()),
|
||||
("PatientId", dto.PatientId.ToString())
|
||||
};
|
||||
|
||||
var appointments = await FindAsync<Appointment>(criteria);
|
||||
|
||||
foreach (var app in appointments)
|
||||
{
|
||||
if (app.AppointmentsList.Any(a => a.Date == appointment.Date))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<bool> DoesAppointmentExists(AppointmentManagementDto dto)
|
||||
{
|
||||
var appointment = dto.Appointment.ToUniversalTime();
|
||||
|
||||
var criteria = new List<(string FieldName, string Value)>
|
||||
{
|
||||
("DoctorId", dto.DoctorId.ToString()),
|
||||
("PatientId", dto.PatientId.ToString())
|
||||
};
|
||||
|
||||
var appointments = await FindAsync<Appointment>(criteria);
|
||||
|
||||
foreach (var app in appointments)
|
||||
{
|
||||
if (app.AppointmentsList.Any(a => a.Date == appointment.Date))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -70,5 +70,12 @@ namespace Infrastructure.Services.MongoDB
|
||||
var filter = Builders<T>.Filter.Eq(keyField, keyValue);
|
||||
await collection.DeleteOneAsync(filter);
|
||||
}
|
||||
|
||||
public async Task DeleteByIdAsync<T>(string id)
|
||||
{
|
||||
var collection = _database.GetDatabase(_databaseName).GetCollection<T>(_collectionName);
|
||||
var filter = Builders<T>.Filter.Eq("_id", id);
|
||||
await collection.DeleteOneAsync(filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user