finalizare 1.0
This commit is contained in:
+33
@@ -0,0 +1,33 @@
|
||||
using Application.Endpoints.MedicalHistories.ManageAuthorization;
|
||||
using Application.Services.Database.MongoDB;
|
||||
using Application.Services.Database.PostgreSQL;
|
||||
|
||||
namespace Application.Endpoints.MedicalHistories.DeleteMedicalHistory;
|
||||
|
||||
public class DeleteMedicalHistoryHandler(
|
||||
IMedicalHistoryRepository medicalHistoryRepository,
|
||||
IMedicalHistoryMongoDbService medicalHistoryMongoDbService)
|
||||
{
|
||||
public async Task<BaseResponse> Handle(Guid id, CancellationToken token)
|
||||
{
|
||||
var medicalRecord = await medicalHistoryRepository.GetByIdAsync(id, token);
|
||||
if (medicalRecord == null)
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.NotFound,
|
||||
Message = "Medical record is not in system.",
|
||||
Data = null
|
||||
};
|
||||
|
||||
await medicalHistoryRepository.DeleteAsync(medicalRecord, token);
|
||||
await medicalHistoryMongoDbService.DeleteAsync<MedicalHistoryAuthorisationModel>(
|
||||
"_id", id.ToString(), token);
|
||||
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.NoContent,
|
||||
Message = null,
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user