jwt v1.0
This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
||||
using Application.Services.Database;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Application.Endpoints.MedicalHistories.FileManagement;
|
||||
|
||||
public class MedicalHistoryUpdateValidation : AbstractValidator<MedicalHistoryUpdateDto>
|
||||
{
|
||||
private readonly IMedicalHistoryRepository _medicalHistoryRepository;
|
||||
private readonly IPatientRepository _patientRepository;
|
||||
|
||||
public MedicalHistoryUpdateValidation(IMedicalHistoryRepository medicalHistoryRepository,
|
||||
IPatientRepository patientRepository)
|
||||
{
|
||||
_medicalHistoryRepository = medicalHistoryRepository;
|
||||
_patientRepository = patientRepository;
|
||||
|
||||
RuleFor(x => x.Id)
|
||||
.NotEmpty().WithMessage("Id is required")
|
||||
.MustAsync(BeExistingMedicalHistoryRecord).WithMessage("Medical history record does not exist");
|
||||
|
||||
RuleFor(x => x.Content)
|
||||
.NotEmpty().WithMessage("Description is required.");
|
||||
}
|
||||
|
||||
private async Task<bool> BeExistingMedicalHistoryRecord(Guid guid, CancellationToken token)
|
||||
{
|
||||
var record = await _medicalHistoryRepository.GetByIdAsync(guid);
|
||||
return record != null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user