public void SendIdeaResolvedNotification(IdeaResolvedNotification notification, string ideaId, string link) { var users = new List <string>(); using (var session = usersSessionFactory.CreateContext()) { using (var noSqlsession = noSqlSessionFactory()) { var idea = noSqlsession.GetSingle <Data.MongoDB.Idea>(i => i.Id == ideaId); if (idea == null) { return; } notification.ObjectSubject = idea.Subject; notification.Deadline = idea.Deadline.HasValue ? idea.Deadline.Value.ToString() : "Nėra"; if (idea.InitiativeType.HasValue) { notification.InitiativeType = Globalization.Resources.Services.InitiativeTypes.ResourceManager.GetString(idea.InitiativeType.ToString()); } else { notification.InitiativeType = "Pilietinė iniciatyva"; } foreach (var version in idea.SummaryWiki.Versions) { foreach (var su in version.SupportingUsers) { foreach (var email in session.UserEmails.Where(u => u.User.ObjectId == su.Id && u.IsEmailConfirmed && u.SendMail)) { users.Add(email.Email); } } } } var not = session.Notifications.Single(n => n.Id == (int)NotificationTypes.IdeaResolved); notification.MessageTemplate = not.Message; notification.Subject = not.Subject; notification.ObjectLink = link; } foreach (var mailUser in users) { notification.To = mailUser; notification.Execute(); } }
public IdeaCommandHandler(NotificationService notificationService, ObjectCreatedNotification notification, IdeaResolvedNotification resolvedNotification) { this.notificationService = notificationService; this.notification = notification; this.resolvedNotification = resolvedNotification; }
public IdeaResolvedCommandHandler(IdeaResolvedNotification resolvedNotification) { this.resolvedNotification = resolvedNotification; }