serviciu email done

This commit is contained in:
andrei-mihnea-cerbu
2024-04-09 03:03:44 +03:00
parent 0d03c0ea43
commit 9977a9b5f5
63 changed files with 135 additions and 17 deletions
+12 -1
View File
@@ -5,6 +5,7 @@ using Application.Endpoints.Doctors.Registration;
using Application.Endpoints.Doctors.ResetPassword;
using Application.Services.Database.MongoDB;
using Application.Services.Database.PostgreSQL;
using Application.Services.Email;
using Application.Services.HashingAlgorithms;
using Application.Services.Jwt;
using Core.Entities;
@@ -20,14 +21,16 @@ public class DoctorsController : ControllerBase
private readonly IDoctorRepository _database;
private readonly IHashingAlgorithms _hashingAlgorithms;
private readonly IJwtService _jwtService;
private readonly IEmailService _emailService;
public DoctorsController(IDoctorRepository database, IHashingAlgorithms hashingAlgorithms,
IJwtService jwtService, IAppointmentsMongoDbService appointmentsMongoDbService)
IJwtService jwtService, IAppointmentsMongoDbService appointmentsMongoDbService, IEmailService emailService)
{
_database = database;
_hashingAlgorithms = hashingAlgorithms;
_jwtService = jwtService;
_appointmentsMongoDbService = appointmentsMongoDbService;
_emailService = emailService;
}
[HttpPost("register")]
@@ -35,6 +38,14 @@ public class DoctorsController : ControllerBase
{
var handler = new DoctorRegistrationHandler(_database, _hashingAlgorithms);
var response = await handler.Handle(doctorRegistrationDto).ConfigureAwait(false);
if (response.StatusCode < HttpStatusCodes.BadRequest)
{
var body = _emailService.GenerateCredentialsEmailBody(
doctorRegistrationDto.Email, doctorRegistrationDto.Password);
await _emailService.SendEmailAsync(doctorRegistrationDto.Email, "Successful registration!", body);
}
return StatusCode(response.StatusCode, response);
}