serviciu email done
This commit is contained in:
@@ -5,7 +5,9 @@ using Application.Endpoints.Patients.Registration;
|
||||
using Application.Endpoints.Patients.ResetPassword;
|
||||
using Application.Services.Database.PostgreSQL;
|
||||
using Application.Services.HashingAlgorithms;
|
||||
using Application.Services.Email;
|
||||
using Application.Services.Jwt;
|
||||
using Core.Entities;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace API.Controllers;
|
||||
@@ -18,14 +20,16 @@ public class PatientsController : ControllerBase
|
||||
private readonly IJwtService _jwtService;
|
||||
private readonly IMedicalHistoryRepository _medicalHistory;
|
||||
private readonly IPatientRepository _patientRepository;
|
||||
private readonly IEmailService _emailService;
|
||||
|
||||
public PatientsController(IPatientRepository patientRepository, IHashingAlgorithms hashingAlgorithms,
|
||||
IJwtService jwtService, IMedicalHistoryRepository medicalHistory)
|
||||
IJwtService jwtService, IMedicalHistoryRepository medicalHistory, IEmailService emailService)
|
||||
{
|
||||
_patientRepository = patientRepository;
|
||||
_hashingAlgorithms = hashingAlgorithms;
|
||||
_jwtService = jwtService;
|
||||
_medicalHistory = medicalHistory;
|
||||
_emailService = emailService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@@ -97,6 +101,14 @@ public class PatientsController : ControllerBase
|
||||
{
|
||||
var handler = new PatientRegistrationHandler(_patientRepository, _hashingAlgorithms);
|
||||
var response = await handler.Handle(patientRegistrationDto).ConfigureAwait(false);
|
||||
|
||||
if (response.StatusCode < HttpStatusCodes.BadRequest)
|
||||
{
|
||||
var body = _emailService.GenerateCredentialsEmailBody(
|
||||
patientRegistrationDto.Email, patientRegistrationDto.Password);
|
||||
await _emailService.SendEmailAsync(patientRegistrationDto.Email, "Successful registration!", body);
|
||||
}
|
||||
|
||||
return StatusCode(response.StatusCode, response);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user