Backend Pacients, Doctors and MedicalHistory endpoints
- added for Pacients: POST: /register POST: /login POST: /reset_password PUT: /profile DELETE: /profile - added for Doctors: POST: /register POST: /login POST: /reset_password PUT: /profile DELETE: /profile - added for MedicalHistories: POST: /:id (only by pacient) - done GET: /:id (only by pacient) - done PUT: /:id (only by doctor) - done PUT /grand_access - TODO
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using Application.Services.Database;
|
||||
|
||||
namespace Application.Endpoints.Pacients.Login;
|
||||
|
||||
public class PacientLoginHandler
|
||||
{
|
||||
private readonly IPacientRepository _database;
|
||||
|
||||
public PacientLoginHandler(IPacientRepository database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public async Task<BaseResponse> Handle(PacientLoginDTO loginDTO)
|
||||
{
|
||||
var validation = new PacientLoginValidation(_database);
|
||||
var validationResult = await validation.ValidateAsync(loginDTO);
|
||||
|
||||
if (!validationResult.IsValid)
|
||||
{
|
||||
var errorMessage = validationResult.Errors.FirstOrDefault()?.ErrorMessage;
|
||||
return new BaseResponse
|
||||
{
|
||||
Success = false,
|
||||
Message = errorMessage,
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
|
||||
return new BaseResponse
|
||||
{
|
||||
Success = true,
|
||||
Message = "Authentication successful",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user