API Traieste
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using Application.Services.Database;
|
||||
|
||||
namespace Application.Endpoints.Doctors.Login
|
||||
{
|
||||
public class DoctorLoginHandler
|
||||
{
|
||||
private readonly IDoctorRepository _database;
|
||||
|
||||
public DoctorLoginHandler(IDoctorRepository database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public async Task<BaseResponse> Handle(DoctorLoginDTO loginDTO)
|
||||
{
|
||||
var validation = new DoctorLoginValidation(_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