20-11-23
This commit is contained in:
@@ -15,6 +15,8 @@ namespace EnvelopeGenerator.Web.Services
|
||||
public ElementModel elementModel;
|
||||
public HistoryModel historyModel;
|
||||
public DocumentStatusModel documentStatusModel;
|
||||
public EmailModel emailModel;
|
||||
public ConfigModel configModel;
|
||||
|
||||
public ModelContainer(State state)
|
||||
{
|
||||
@@ -24,6 +26,8 @@ namespace EnvelopeGenerator.Web.Services
|
||||
elementModel = new(state);
|
||||
historyModel = new(state);
|
||||
documentStatusModel = new(state);
|
||||
emailModel = new(state);
|
||||
configModel = new(state);
|
||||
}
|
||||
}
|
||||
public readonly ModelContainer? Models;
|
||||
@@ -39,8 +43,17 @@ namespace EnvelopeGenerator.Web.Services
|
||||
{
|
||||
logger.Debug("MSSQL Connection: [{0}]", MSSQL.CurrentConnectionString);
|
||||
|
||||
// There is a circular dependency between state and models
|
||||
// All models need a state object, including the config Model
|
||||
// The state object needs to be filled with the DbConfig property,
|
||||
// which is obtained by the config Model.
|
||||
// So first, the config model is initialized with an incomplete state object,
|
||||
// then all the other models with the DbConfig property filled.
|
||||
var state = GetState();
|
||||
Models = new(state);
|
||||
var configModel = new ConfigModel(state);
|
||||
state.DbConfig = configModel.LoadConfiguration();
|
||||
|
||||
Models = new(state);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
38
EnvelopeGenerator.Web/Services/EmailService.cs
Normal file
38
EnvelopeGenerator.Web/Services/EmailService.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using EnvelopeGenerator.Common;
|
||||
|
||||
namespace EnvelopeGenerator.Web.Services
|
||||
{
|
||||
public class EmailService : BaseService
|
||||
{
|
||||
private ReceiverModel receiverModel;
|
||||
private EnvelopeModel envelopeModel;
|
||||
private HistoryModel historyModel;
|
||||
private DocumentModel documentModel;
|
||||
private DocumentStatusModel documentStatusModel;
|
||||
private EmailModel emailModel;
|
||||
|
||||
public EmailService(IConfiguration Config, LoggingService Logging, DatabaseService database) : base(Config, Logging)
|
||||
{
|
||||
logger = Logging.LogConfig.GetLogger();
|
||||
|
||||
if (database.Models == null)
|
||||
{
|
||||
throw new ArgumentNullException("Models not loaded.");
|
||||
}
|
||||
|
||||
receiverModel = database.Models.receiverModel;
|
||||
envelopeModel = database.Models.envelopeModel;
|
||||
historyModel = database.Models.historyModel;
|
||||
documentModel = database.Models.documentModel;
|
||||
documentStatusModel = database.Models.documentStatusModel;
|
||||
emailModel = database.Models.emailModel;
|
||||
}
|
||||
|
||||
public bool SendEmail(EmailData emailData)
|
||||
{
|
||||
return emailModel.Insert(emailData);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user