serviciu email done
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,14 @@
|
||||
"Audience": "HealthCareManagerUsers",
|
||||
"ExpirationTime": 1440
|
||||
},
|
||||
"SmtpSettings": {
|
||||
"Host": "smtp-relay.brevo.com",
|
||||
"Port": 587,
|
||||
"From": "bot@healthcaremanager.com",
|
||||
"EnableSSL": false,
|
||||
"UserName": "andreimihneacerbu@gmail.com",
|
||||
"Password": "zpK3w71LkNa0sGt6"
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"Kestrel": {
|
||||
"Endpoints": {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -24,6 +24,14 @@
|
||||
"Audience": "HealthCareManagerUsers",
|
||||
"ExpirationTime": 1440
|
||||
},
|
||||
"SmtpSettings": {
|
||||
"Host": "smtp-relay.brevo.com",
|
||||
"Port": 587,
|
||||
"From": "bot@healthcaremanager.com",
|
||||
"EnableSSL": false,
|
||||
"UserName": "andreimihneacerbu@gmail.com",
|
||||
"Password": "zpK3w71LkNa0sGt6"
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"Kestrel": {
|
||||
"Endpoints": {
|
||||
|
||||
@@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("API")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+015a1a9c09fe601a8c8b9f61de5c7d87b5a73607")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0d03c0ea4308c032d708d3ee63f648b10811c65f")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("API")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("API")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@@ -1 +1 @@
|
||||
fe88730eccbbece1fca0539b2a9e626db000fc875172a108baa980cc6e2addff
|
||||
9da6326faa16b70419b8bad27961193604ad75fcbf0f437bde7752d1858a93b2
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
{"documents":{"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\*":"https://raw.githubusercontent.com/andrei-mihnea-cerbu/CC-FinalProj/015a1a9c09fe601a8c8b9f61de5c7d87b5a73607/*"}}
|
||||
{"documents":{"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\*":"https://raw.githubusercontent.com/andrei-mihnea-cerbu/CC-FinalProj/0d03c0ea4308c032d708d3ee63f648b10811c65f/*"}}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user