public void NotifyAboutNewComment(Comment comment, ApplicationUser commentCreator) { var organization = _organizationService.GetOrganizationById(commentCreator.OrganizationId); var destinationEmails = _userService.GetPostCommentersEmails(commentCreator.Email, comment.PostId); var postAuthorEmail = (comment.Post.AuthorId == comment.AuthorId) ? null : _userService.GetPostAuthorEmail(comment.Post.AuthorId); if (postAuthorEmail != null && destinationEmails.Contains(postAuthorEmail) == false) { destinationEmails.Add(postAuthorEmail); } if (destinationEmails.Count > 0) { var postLink = GetPostLink(comment.Post.Wall.Type, comment.Post.WallId, organization.ShortName, comment.Post.Id); var authorPictureUrl = _appSettings.PictureUrl(organization.ShortName, commentCreator.PictureId); var userNotificationSettingsUrl = _appSettings.UserNotificationSettingsUrl(organization.ShortName); var subject = string.Format(Templates.NewPostCommentEmailSubject, CutMessage(comment.Post.MessageBody), commentCreator.FullName); var body = _markdownConverter.ConvertToHtml(comment.MessageBody); var emailTemplateViewModel = new NewCommentEmailTemplateViewModel( string.Format(Constants.BusinessLayer.Templates.PostCommentTitle, CutMessage(comment.Post.MessageBody)), authorPictureUrl, commentCreator.FullName, postLink, body, userNotificationSettingsUrl, Constants.BusinessLayer.Templates.DefautlActionButtonTitle); var content = _mailTemplate.Generate(emailTemplateViewModel, EmailTemplateCacheKeys.NewPostComment); var emailData = new EmailDto(destinationEmails, subject, content); _mailingService.SendEmail(emailData); } }
public void SendEmailNotification(CommentCreatedDTO commentDto) { var commentCreator = _userService.GetApplicationUser(commentDto.CommentCreator); var organization = _organizationService.GetOrganizationById(commentCreator.OrganizationId); var destinationEmails = GetPostWatchersEmails(commentCreator.Email, commentDto.PostId, commentCreator.Id); if (destinationEmails.Count <= 0) { return; } var comment = LoadComment(commentDto.CommentId); var postLink = GetPostLink(commentDto.WallType, commentDto.WallId, organization.ShortName, commentDto.PostId); var authorPictureUrl = _appSettings.PictureUrl(organization.ShortName, commentCreator.PictureId); var userNotificationSettingsUrl = _appSettings.UserNotificationSettingsUrl(organization.ShortName); var subject = string.Format(Templates.NewPostCommentEmailSubject, CutMessage(comment.Post.MessageBody), commentCreator.FullName); var body = _markdownConverter.ConvertToHtml(comment.MessageBody); var emailTemplateViewModel = new NewCommentEmailTemplateViewModel( string.Format(Constants.BusinessLayer.Templates.PostCommentTitle, CutMessage(comment.Post.MessageBody)), authorPictureUrl, commentCreator.FullName, postLink, body, userNotificationSettingsUrl, Constants.BusinessLayer.Templates.DefautlActionButtonTitle); var content = _mailTemplate.Generate(emailTemplateViewModel, EmailTemplateCacheKeys.NewPostComment); var emailData = new EmailDto(destinationEmails, subject, content); _mailingService.SendEmail(emailData); }
private void SendPostWatcherEmails(CommentCreatedDTO commentDto, IList <string> emails, ApplicationUser commentCreator, Organization organization) { var comment = LoadComment(commentDto.CommentId); var postLink = GetPostLink(commentDto.WallType, commentDto.WallId, organization.ShortName, commentDto.PostId); var authorPictureUrl = _appSettings.PictureUrl(organization.ShortName, commentCreator.PictureId); var userNotificationSettingsUrl = _appSettings.UserNotificationSettingsUrl(organization.ShortName); var subject = string.Format(Templates.NewPostCommentEmailSubject, CutMessage(comment.Post.MessageBody), commentCreator.FullName); var body = _markdownConverter.ConvertToHtml(comment.MessageBody); var emailTemplateViewModel = new NewCommentEmailTemplateViewModel( string.Format(EmailTemplates.PostCommentTitle, CutMessage(comment.Post.MessageBody)), authorPictureUrl, commentCreator.FullName, postLink, body, userNotificationSettingsUrl, EmailTemplates.DefaultActionButtonTitle); var content = _mailTemplate.Generate(emailTemplateViewModel, EmailTemplateCacheKeys.NewPostComment); var emailData = new EmailDto(emails, subject, content); _mailingService.SendEmail(emailData); }