// __ Impl ____________________________________________________________ private Notification CreateNotification(IDbConnection c, IDbTransaction t, string templateKey, BaseTemplateData notificationData) { var notification = TemplateEngine.GetNotificationFromDbTemplate(c, t, mConfig.DefaultLocale, templateKey, notificationData); SetupNotification(notification, notificationData); c.Insert(notification, t); return(notification); }
public void NotifyPush(HttpRequest req, IDbConnection c, IDbTransaction t, string templateKey, BaseTemplateData notificationData) { var n = CreateNotification(c, t, templateKey, notificationData); // Queue through the push provider }
private void SetupNotification(Notification notification, BaseTemplateData data) { SetupNotification(notification, data.From, data.To); }
public void NotifyEmail(HttpRequest req, IDbConnection c, IDbTransaction t, string templateKey, BaseTemplateData notificationData) { var n = CreateNotification(c, t, templateKey, notificationData); // Queue through the email provider var result = mEmailProvider.SendEmail(req, n.RecipientData.Email, n.Text2, null, n.Text); if (!result) { throw new Exception("Error.SendingEmailFailed"); } }
public static Notification GetNotificationFromDbTemplate(IDbConnection c, IDbTransaction t, string lang, string templateKey, BaseTemplateData data) { if (data == null || data.To == null || data.From == null) { throw new ArgumentNullException(); } var template = c.QueryFirstOrDefault <NotificationTemplate>( "SELECT * FROM notificationTemplates WHERE lang = @lang AND key = @key", new { lang = lang, key = templateKey }, t); if (template == null) { throw new Exception("Error.NotFound.Template"); } var result = new Notification { Text = Process(template.ContentTemplate, data), Text2 = Process(template.Title, data), }; return(result); }