40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
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
|
|
};
|
|
}
|
|
}
|
|
}
|