mailling template key

This commit is contained in:
Paul Schneider 2021-05-30 13:48:24 +01:00
commit acdec2b6f7
12 changed files with 3141 additions and 110 deletions

View file

@ -9,17 +9,12 @@ using System.Linq;
using Yavsc.Models;
using System.Collections.Generic;
using System;
using Yavsc.Templates;
namespace cli
{
public class SendMailCommandProvider : ICommander
{
readonly Dictionary<string, Func<ApplicationUser, bool>> Criterias =
new Dictionary<string, Func<ApplicationUser, bool>>
{
{"allow-monthly", u => u.AllowMonthlyEmail },
{ "email-not-confirmed", u => !u.EmailConfirmed }
};
public CommandLineApplication Integrate(CommandLineApplication rootApp)
{
@ -43,9 +38,7 @@ namespace cli
sendMailCommandApp.OnExecute(() =>
{
int code;
bool showhelp = !int.TryParse(codeCommandArg.Value, out code)
|| Criterias.ContainsKey(critCommandArg.Value);
bool showhelp = TemplateConstants.Criterias.ContainsKey(critCommandArg.Value);
if (!showhelp)
{
@ -60,7 +53,7 @@ namespace cli
var loggerFactory = app.Services.GetService<ILoggerFactory>();
var logger = loggerFactory.CreateLogger<Program>();
logger.LogInformation("Starting emailling");
mailer.SendEmailFromCriteria(code, Criterias[critCommandArg.Value]);
mailer.SendEmailFromCriteria(critCommandArg.Value, TemplateConstants.Criterias[critCommandArg.Value]);
logger.LogInformation("Finished emailling");
}
else

View file

@ -61,7 +61,7 @@ namespace cli.Services
}
public void SendEmailFromCriteria(long templateCode, Func<ApplicationUser,bool> criteria)
public void SendEmailFromCriteria(string templateCode, Func<ApplicationUser,bool> criteria)
{
string className = "GeneratedTemplate";