SendNotificationResult INotificationManager.SendNotification(Core.Notification.Notification notification) { ResolveTemplate(notification); var result = notification.SendNotification(); return(result); }
public void UpdateNotification(Core.Notification.Notification notification) { using (var repository = _repositoryFactory()) { repository.Update(notification.ToDataModel()); repository.UnitOfWork.Commit(); } }
public static NotificationEntity ToDataModel(this Core.Notification.Notification notification) { NotificationEntity retVal = new NotificationEntity(); retVal.InjectFrom(notification); retVal.SendingGateway = notification.NotificationSendingGateway.GetType().Name; return(retVal); }
public void SheduleSendNotification(Core.Notification.Notification notification) { ResolveTemplate(notification); using (var repository = _repositoryFactory()) { var addedNotification = notification.ToDataModel(); repository.Add(addedNotification); repository.UnitOfWork.Commit(); } }
public void SheduleSendNotification(Core.Notification.Notification notification) { ResolveTemplate(notification); using (var repository = _repositoryFactory()) { notification.Id = Guid.NewGuid().ToString("N"); repository.Add(notification.ToDataModel()); repository.UnitOfWork.Commit(); } }
private void SetNotificationTemplate(Core.Notification.Notification notification) { if (notification != null) { var template = _notificationTemplateService.GetByNotification(notification.Type, notification.ObjectId); if (template != null) { notification.NotificationTemplate = template; } } }
public Core.Notification.Notification GetNotificationById(string id) { Core.Notification.Notification retVal = null; using (var repository = _repositoryFactory()) { var notificationEntity = repository.Notifications.FirstOrDefault(x => x.Id == id); if (notificationEntity != null) { retVal = GetNotificationCoreModel(notificationEntity); } } return(retVal); }
public Core.Notification.Notification GetNotification(string id) { Core.Notification.Notification retVal = null; using (var repository = _repositoryFactory()) { var notification = repository.Notifications.FirstOrDefault(n => n.Id == id); if (notification != null) { retVal = GetNotificationCoreModel(notification); } } return(retVal); }
public void ResolveTemplate(Core.Notification.Notification notification) { Template templateSubject = Template.Parse(notification.NotificationTemplate.Subject); notification.Subject = templateSubject.Render(Hash.FromAnonymousObject(new { context = notification })); Template templateBody = Template.Parse(notification.NotificationTemplate.Body); notification.Body = templateBody.Render(Hash.FromAnonymousObject(new { context = notification })); }
public void ResolveTemplate(Core.Notification.Notification notification) { var parameters = ResolveNotificationParameters(notification); Dictionary <string, object> myDict = new Dictionary <string, object>(); foreach (var parameter in parameters) { myDict.Add(parameter.ParameterName, notification.GetType().GetProperty(parameter.ParameterName).GetValue(notification)); } Template templateSubject = Template.Parse(notification.NotificationTemplate.Subject); notification.Subject = templateSubject.Render(Hash.FromDictionary(myDict)); Template templateBody = Template.Parse(notification.NotificationTemplate.Body); notification.Body = templateBody.Render(Hash.FromDictionary(myDict)); }
public NotificationParameter[] ResolveNotificationParameters(Core.Notification.Notification notification) { var retVal = new List <NotificationParameter>(); List <PropertyInfo> properties = notification.GetType().GetProperties().Where(p => p.GetCustomAttributes(typeof(NotificationParameterAttribute), true).Any()).ToList(); if (properties.Count > 0) { foreach (var property in properties) { var attributes = property.GetCustomAttributes(typeof(NotificationParameterAttribute), true); retVal.Add(new NotificationParameter { ParameterName = property.Name, ParameterDescription = attributes.Length > 0 ? ((NotificationParameterAttribute)(attributes[0])).Description : string.Empty, ParameterCodeInView = GetLiquidCodeOfParameter(property.Name) }); } } return(retVal.ToArray()); }
public SendNotificationResult SendNotification(Core.Notification.Notification notification) { var retVal = new SendNotificationResult(); SendGridMessage mail = new SendGridMessage(); mail.From = new MailAddress(notification.Sender); mail.AddTo(notification.Recipient); mail.Subject = notification.Subject; mail.Html = notification.Body; var userName = _settingsManager.GetSettingByName(sendGridUserNameSettingName).Value; var password = _settingsManager.GetSettingByName(sendGridPasswordSettingName).Value; var credentials = new NetworkCredential(userName, password); var transportWeb = new Web(credentials); try { transportWeb.DeliverAsync(mail).Wait(); retVal.IsSuccess = true; } catch (Exception ex) { retVal.ErrorMessage = ex.Message; if (ex.InnerException is InvalidApiRequestException) { var apiEx = ex.InnerException as InvalidApiRequestException; if (apiEx.Errors != null && apiEx.Errors.Length > 0) { retVal.ErrorMessage = string.Join(" ", apiEx.Errors); } } } return(retVal); }
public bool ValidateNotification(Core.Notification.Notification notification) { throw new NotImplementedException(); }
public SendNotificationResult SendNotification(Core.Notification.Notification notification) { throw new NotImplementedException(); }
private void ResolveTemplate(Core.Notification.Notification notification) { GetNewNotification(notification.GetType().Name, notification.ObjectId, notification.ObjectTypeId, notification.Language); _resolver.ResolveTemplate(notification); }
private void ResolveTemplate(Core.Notification.Notification notification) { SetNotificationTemplate(notification); _resolver.ResolveTemplate(notification); }