- Tag br in appsettings
- Attribute per controllo validità email
This commit is contained in:
@ -14,8 +14,8 @@
|
|||||||
"RangeSize": 20,
|
"RangeSize": 20,
|
||||||
"From": "registrazioni@gruppodac.eu",
|
"From": "registrazioni@gruppodac.eu",
|
||||||
"MailSplitCharTo": ";",
|
"MailSplitCharTo": ";",
|
||||||
"To": "g.vitari@oaservice.it;d.sandrelli@oaservice.it",
|
"To": "g.vitari@oaservice.it",
|
||||||
"Subject": "Registrazione",
|
"Subject": "Registrazione",
|
||||||
"MailSplitCharBody": ";"
|
"MailSplitCharBody": "<br />"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,7 +28,7 @@ public class RegistrazioneMailProcessor : IMailProcessor
|
|||||||
foreach (var chunk in mailQueueList.Chunk(size))
|
foreach (var chunk in mailQueueList.Chunk(size))
|
||||||
{
|
{
|
||||||
|
|
||||||
string body = string.Join("<br />", chunk.Select(x => x.ToList));
|
string body = string.Join(_config.MailSplitCharBody, chunk.Select(x => x.ToList));
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
@using StandManager.Components.Layout
|
@using StandManager.Components.Layout
|
||||||
@using StandManager.Components.Widget
|
@using StandManager.Components.Widget
|
||||||
|
@using StandManager.Model
|
||||||
|
|
||||||
@page "/"
|
@page "/"
|
||||||
@page "/Registrazione"
|
@page "/Registrazione"
|
||||||
@ -26,9 +27,9 @@
|
|||||||
<div class="col-3"></div>
|
<div class="col-3"></div>
|
||||||
<div class="col-6 mb-3">
|
<div class="col-6 mb-3">
|
||||||
<RadzenFormField Text="Email" Variant="Variant.Flat" Style="width: 100%;">
|
<RadzenFormField Text="Email" Variant="Variant.Flat" Style="width: 100%;">
|
||||||
<RadzenTextBox Style="width: 100%" aria-label="Nome" Placeholder="es. nome@azienda.com" @bind-Value="@mail" />
|
<RadzenTextBox Style="width: 100%" aria-label="Email" Placeholder="es. nome@azienda.com" @bind-Value="@mail.Email" />
|
||||||
</RadzenFormField>
|
</RadzenFormField>
|
||||||
<ValidationMessage For="@(() => mail)" />
|
<ValidationMessage For="@(() => mail.Email)" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -69,19 +70,14 @@
|
|||||||
<DacFooter />
|
<DacFooter />
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private string mail { get; set; } = "";
|
private RegistrazioneViewModel mail { get; set; } = new();
|
||||||
|
|
||||||
private bool PresaVisionePrivacy { get; set; }
|
private bool PresaVisionePrivacy { get; set; }
|
||||||
private bool PresaVisioneDatiPersonali { get; set; }
|
private bool PresaVisioneDatiPersonali { get; set; }
|
||||||
|
|
||||||
private async Task OnIscrizioneSave()
|
private async Task OnIscrizioneSave()
|
||||||
{
|
{
|
||||||
if (!mail.Contains("@") || mail.Contains("@ "))
|
var exist = await _managerService.MailQueueService.RicercaPer(x => x.ToList.Contains(mail.Email) && !x.Eliminato);
|
||||||
{
|
|
||||||
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);
|
|
||||||
if (exist != null && exist?.Id != Guid.Empty)
|
if (exist != null && exist?.Id != Guid.Empty)
|
||||||
{
|
{
|
||||||
await _dialogService.Alert("L'indirizzo mail indicato è già stato utilizzato", "Errore", new ConfirmOptions() { OkButtonText = "Ok" });
|
await _dialogService.Alert("L'indirizzo mail indicato è già stato utilizzato", "Errore", new ConfirmOptions() { OkButtonText = "Ok" });
|
||||||
@ -90,7 +86,7 @@
|
|||||||
|
|
||||||
var queue = new MailQueue()
|
var queue = new MailQueue()
|
||||||
{
|
{
|
||||||
ToList = mail,
|
ToList = mail.Email,
|
||||||
From = MailFrom.Registrazione,
|
From = MailFrom.Registrazione,
|
||||||
Body = string.Empty,
|
Body = string.Empty,
|
||||||
Sent = false,
|
Sent = false,
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
using StandManager.Domain.Entita;
|
using StandManager.Domain.Entita;
|
||||||
using StandManager.Service.Mail;
|
using StandManager.Service.Mail;
|
||||||
|
using StandManager.Utils;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
@ -23,7 +24,7 @@ public class IscrizioneEventoViewModel
|
|||||||
[Required(ErrorMessage = "Il cognome è obbigatorio")]
|
[Required(ErrorMessage = "Il cognome è obbigatorio")]
|
||||||
public string Cognome { get; set; }
|
public string Cognome { get; set; }
|
||||||
[Required(ErrorMessage = "La E-mail è obbigatoria")]
|
[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; }
|
public string Email { get; set; }
|
||||||
[Required(ErrorMessage = "Il numero di telefono è obbigatorio")]
|
[Required(ErrorMessage = "Il numero di telefono è obbigatorio")]
|
||||||
public string NumeroTelefono { get; set; }
|
public string NumeroTelefono { get; set; }
|
||||||
|
|||||||
16
StandManager/Model/RegistrazioneViewModel.cs
Normal file
16
StandManager/Model/RegistrazioneViewModel.cs
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
using StandManager.Domain.Entita;
|
using StandManager.Domain.Entita;
|
||||||
|
using StandManager.Utils;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace StandManager.Model;
|
namespace StandManager.Model;
|
||||||
@ -8,7 +9,7 @@ public class UtenteViewModel
|
|||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
[Required(ErrorMessage = "L'email è obbligatoria")]
|
[Required(ErrorMessage = "L'email è obbligatoria")]
|
||||||
[EmailAddress(ErrorMessage = "Email non valida")]
|
[EmailCheck(ErrorMessage = "Email non valida")]
|
||||||
public string Email { get; set; }
|
public string Email { get; set; }
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
[Required(ErrorMessage = "Il nome è obbligatorio")]
|
[Required(ErrorMessage = "Il nome è obbligatorio")]
|
||||||
|
|||||||
19
StandManager/Utils/EmailCheckAttribute.cs
Normal file
19
StandManager/Utils/EmailCheckAttribute.cs
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user