/// <summary> /// Creates empty instance of the <see cref="CESMailingTemplate"/>. /// </summary> /// <param name="userConnection">Instance of the user connection.</param> /// <param name="bulkEmail">Instance of the bulk email.</param> /// <param name="macroParser">Instance of the macros helper.</param> public CESMailingTemplate(UserConnection userConnection, BulkEmail bulkEmail, BulkEmailMacroParser macroParser) { _userConnection = userConnection; _bulkEmail = bulkEmail; _macroParser = macroParser; }
/// <summary> /// Creates instance of the <see cref="IMailingTemplate"/> for every replica of dynamic content. /// </summary> /// <param name="userConnection">Instance of the user connection.</param> /// <param name="bulkEmail">Instance of the bulk email.</param> /// <param name="macroParser">Instance of the <see cref="BulkEmailMacroParser"/>.</param> /// <returns>Returns instance of the <see cref="IMailingTemplate"/>.</returns> public IEnumerable <IMailingTemplate> CreateDCTemplates(UserConnection userConnection, BulkEmail bulkEmail, BulkEmailMacroParser macroParser) { var templateRepository = CreateDcTemplateRepository(userConnection); var templateReadOptions = new DCRepositoryReadOptions <DCTemplateModel, DCReplicaModel> { TemplateReadOptions = DCTemplateReadOption.None }; var template = templateRepository.ReadByRecordId(bulkEmail.Id, templateReadOptions); IEnumerable <DCReplicaModel> replicas = null; if (template != null) { replicas = template.Replicas; } return(CreateInstances(userConnection, bulkEmail, replicas, macroParser)); }
/// <summary> /// Creates instance of the <see cref="IMailingTemplate"/> for given replicas of dynamic content. /// </summary> /// <param name="userConnection">Instance of the user connection.</param> /// <param name="bulkEmail">Instance of the bulk email.</param> /// <param name="replicas">Replicas collection.</param> /// <param name="macroParser">Instance of the <see cref="BulkEmailMacroParser"/>.</param> /// <returns>Returns instance of the <see cref="IMailingTemplate"/>.</returns> public virtual IEnumerable <IMailingTemplate> CreateInstances(UserConnection userConnection, BulkEmail bulkEmail, IEnumerable <DCReplicaModel> replicas, BulkEmailMacroParser macroParser = null) { var templateReplicas = new List <IMailingTemplate>(); foreach (var replica in replicas) { var templateFromReplica = new CESMailingTemplate(userConnection, bulkEmail, macroParser); templateFromReplica.Content = replica.Content; templateFromReplica.ReplicaId = replica.Id; templateFromReplica.Init(); templateReplicas.Add(templateFromReplica); } return(templateReplicas); }
/// <summary> /// Creates instance of the <see cref="IMailingTemplate"/>. /// </summary> /// <param name="userConnection">Instance of the user connection.</param> /// <param name="bulkEmail">Instance of the bulk email.</param> /// <param name="macroParser">Instance of the macros parser.</param> /// <returns>Returns instance of the <see cref="IMailingTemplate"/>.</returns> public virtual IMailingTemplate CreateInstance(UserConnection userConnection, BulkEmail bulkEmail, BulkEmailMacroParser macroParser) { return(new CESMailingTemplate(userConnection, bulkEmail, macroParser)); }