Example #1
0
        async Task ISmsSender.SendSmsCommunicationAsync(SystemCommunicationPurposes purpose, object model, string number)
        {
            //var res = await CreateMessageAsync(purpose, model);
            //var body = ((TextPart)res.Item2.Body).Text;
            object body = model?.GetType().GetProperty("code")?.GetValue(model, null);

            await((ISmsSender)this).SendSmsAsync(number, body.ToString());
        }
Example #2
0
        async Task IEmailSender.SendEmailCommunicationAsync(SystemCommunicationPurposes purpose, object model, string recipientAddress, string recipientName, long?contactId)
        {
            var res = await CreateMessageAsync(purpose, model);

            var creative = res.Item1;
            var message  = res.Item2;

            if (contactId != null)
            {
                message.ContactId(contactId.Value);
            }
            message.To.Add(new MailboxAddress(recipientName ?? "", recipientAddress));
            await SendEmailAsync(creative, message);
        }
Example #3
0
        private async Task <Tuple <Creative, MimeMessage> > CreateMessageAsync(SystemCommunicationPurposes purpose, object model)
        {
            int creativeId;
            var creatives = Current.Application.AppSettings.CreativeIdBySystemCommunicationPurpose;

            creatives.TryGetValue(purpose, out creativeId);
            Requires.Positive(creativeId, nameof(creativeId));
            var creative = await DB.Creatives.FindAsync(creativeId);

            Requires.NonNull(creative, nameof(creative));
            var message = new MimeMessage();

            message.Fill(DB, Current.Tenant.TenantSettings.ReusableValues, creative, CommunicationTypes.Email, Current.User, null, model);
            return(Tuple.Create(creative, message));
        }
 public SystemCommunicationsModel(SystemCommunicationPurposes purpose, int creativeId, CommunicationModelTypes modelType)
 {
     Purpose    = purpose;
     CreativeId = creativeId;
     ModelType  = modelType;
 }