- 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
38 lines
970 B
C#
38 lines
970 B
C#
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
|
|
};
|
|
}
|
|
}
|