initial commit from an older template

This commit is contained in:
2025-09-20 22:33:35 +03:00
commit b6778046c2
134 changed files with 6657 additions and 0 deletions

38
Utils/Clients/EmailClient.cs Executable file
View File

@@ -0,0 +1,38 @@
using System.Net.Mail;
using GamificationService.Exceptions.UtilServices.Email;
namespace GamificationService.Utils;
public class EmailClient(SmtpClient smtpClient, string emailFrom, ILogger<EmailClient> logger)
{
#region Fields
private readonly string _emailFrom = emailFrom;
private readonly ILogger<EmailClient> _logger = logger;
#endregion
#region Methods
/// <summary>
/// Sends the email using the SmtpClient instance.
/// </summary>
/// <param name="email">Email to send.</param>
/// <exception cref="SendEmailException">If the SmtpClient instance fails to send the email.</exception>
/// <returns>Task that represents the asynchronous operation.</returns>
public async Task SendEmail(MailMessage email, string emailTo)
{
try
{
email.To.Add(new MailAddress(emailTo));
await smtpClient.SendMailAsync(email);
}
catch (Exception ex)
{
_logger.LogError(ex, ex.Message);
throw new SendEmailException("Failed to send email", ex);
}
}
#endregion
}