diff --git a/StandManager.MailProcessor/appsettings.json b/StandManager.MailProcessor/appsettings.json
index 7a310c7..24e7eef 100644
--- a/StandManager.MailProcessor/appsettings.json
+++ b/StandManager.MailProcessor/appsettings.json
@@ -14,8 +14,8 @@
"RangeSize": 20,
"From": "registrazioni@gruppodac.eu",
"MailSplitCharTo": ";",
- "To": "g.vitari@oaservice.it;d.sandrelli@oaservice.it",
+ "To": "g.vitari@oaservice.it",
"Subject": "Registrazione",
- "MailSplitCharBody": ";"
+ "MailSplitCharBody": "
"
}
}
diff --git a/StandManager.Service/RegistrazioneMailProcessor.cs b/StandManager.Service/RegistrazioneMailProcessor.cs
index f5b7f94..7f663b9 100644
--- a/StandManager.Service/RegistrazioneMailProcessor.cs
+++ b/StandManager.Service/RegistrazioneMailProcessor.cs
@@ -28,7 +28,7 @@ public class RegistrazioneMailProcessor : IMailProcessor
foreach (var chunk in mailQueueList.Chunk(size))
{
- string body = string.Join("
", chunk.Select(x => x.ToList));
+ string body = string.Join(_config.MailSplitCharBody, chunk.Select(x => x.ToList));
try
{
diff --git a/StandManager/Components/Pages/Registrazione.razor b/StandManager/Components/Pages/Registrazione.razor
index 90cf2b6..d7e347a 100644
--- a/StandManager/Components/Pages/Registrazione.razor
+++ b/StandManager/Components/Pages/Registrazione.razor
@@ -1,5 +1,6 @@
@using StandManager.Components.Layout
@using StandManager.Components.Widget
+@using StandManager.Model
@page "/"
@page "/Registrazione"
@@ -26,9 +27,9 @@
-
+
-
+
@@ -69,19 +70,14 @@
@code {
- private string mail { get; set; } = "";
+ private RegistrazioneViewModel mail { get; set; } = new();
private bool PresaVisionePrivacy { get; set; }
private bool PresaVisioneDatiPersonali { get; set; }
private async Task OnIscrizioneSave()
{
- if (!mail.Contains("@") || mail.Contains("@ "))
- {
- await _dialogService.Alert("Inserire un indirizzo Email valido", "Errore", new ConfirmOptions() { OkButtonText = "Ok" });
- return;
- }
- var exist = await _managerService.MailQueueService.RicercaPer(x => x.ToList.Contains(mail) && !x.Eliminato);
+ var exist = await _managerService.MailQueueService.RicercaPer(x => x.ToList.Contains(mail.Email) && !x.Eliminato);
if (exist != null && exist?.Id != Guid.Empty)
{
await _dialogService.Alert("L'indirizzo mail indicato è già stato utilizzato", "Errore", new ConfirmOptions() { OkButtonText = "Ok" });
@@ -90,7 +86,7 @@
var queue = new MailQueue()
{
- ToList = mail,
+ ToList = mail.Email,
From = MailFrom.Registrazione,
Body = string.Empty,
Sent = false,
diff --git a/StandManager/Model/IscrizioneEventoViewModel.cs b/StandManager/Model/IscrizioneEventoViewModel.cs
index 16a6453..fb74ec4 100644
--- a/StandManager/Model/IscrizioneEventoViewModel.cs
+++ b/StandManager/Model/IscrizioneEventoViewModel.cs
@@ -1,5 +1,6 @@
using StandManager.Domain.Entita;
using StandManager.Service.Mail;
+using StandManager.Utils;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -23,7 +24,7 @@ public class IscrizioneEventoViewModel
[Required(ErrorMessage = "Il cognome è obbigatorio")]
public string Cognome { get; set; }
[Required(ErrorMessage = "La E-mail è obbigatoria")]
- [EmailAddress(ErrorMessage = "Inserisci un indirizzo email valido")]
+ [EmailCheck(ErrorMessage = "Inserisci un indirizzo email valido")]
public string Email { get; set; }
[Required(ErrorMessage = "Il numero di telefono è obbigatorio")]
public string NumeroTelefono { get; set; }
diff --git a/StandManager/Model/RegistrazioneViewModel.cs b/StandManager/Model/RegistrazioneViewModel.cs
new file mode 100644
index 0000000..7d48f98
--- /dev/null
+++ b/StandManager/Model/RegistrazioneViewModel.cs
@@ -0,0 +1,16 @@
+using StandManager.Utils;
+using System.ComponentModel.DataAnnotations;
+
+namespace StandManager.Model;
+
+public class RegistrazioneViewModel
+{
+ [Required(ErrorMessage = "L'indirizzo Email è obbligatorio")]
+ [EmailCheck(ErrorMessage = "Inserire un indirizzo Email valido")]
+ public string Email { get; set; }
+
+ public RegistrazioneViewModel()
+ {
+ Email = string.Empty;
+ }
+}
diff --git a/StandManager/Model/UtenteViewModel.cs b/StandManager/Model/UtenteViewModel.cs
index e63f495..f114305 100644
--- a/StandManager/Model/UtenteViewModel.cs
+++ b/StandManager/Model/UtenteViewModel.cs
@@ -1,4 +1,5 @@
using StandManager.Domain.Entita;
+using StandManager.Utils;
using System.ComponentModel.DataAnnotations;
namespace StandManager.Model;
@@ -8,7 +9,7 @@ public class UtenteViewModel
public Guid Id { get; set; }
public string Username { get; set; }
[Required(ErrorMessage = "L'email è obbligatoria")]
- [EmailAddress(ErrorMessage = "Email non valida")]
+ [EmailCheck(ErrorMessage = "Email non valida")]
public string Email { get; set; }
public string Password { get; set; }
[Required(ErrorMessage = "Il nome è obbligatorio")]
diff --git a/StandManager/Utils/EmailCheckAttribute.cs b/StandManager/Utils/EmailCheckAttribute.cs
new file mode 100644
index 0000000..6be29e4
--- /dev/null
+++ b/StandManager/Utils/EmailCheckAttribute.cs
@@ -0,0 +1,19 @@
+using System.ComponentModel.DataAnnotations;
+using System.Text.RegularExpressions;
+
+namespace StandManager.Utils;
+
+public class EmailCheckAttribute : ValidationAttribute
+{
+ protected override ValidationResult? IsValid(object? value, ValidationContext validationContext)
+ {
+ var str = value as string;
+ if (string.IsNullOrEmpty(str)) return ValidationResult.Success;
+
+ if (!Regex.IsMatch(str, "^[\\w-\\.\\+]+@([\\w-]+\\.)+[\\w-]{2,}$"))
+ {
+ return new ValidationResult(ErrorMessage ?? "Inserire un indirizzo Email valido");
+ }
+ return ValidationResult.Success;
+ }
+}