Beispiel #1
0
        private void SendMentionEmails(CommentCreatedDTO commentDto, IList <ApplicationUser> mentionedUsers, ApplicationUser commentCreator, Organization organization)
        {
            var comment = _commentService.GetCommentBody(commentDto.CommentId);
            var userNotificationSettingsUrl = _appSettings.UserNotificationSettingsUrl(organization.ShortName);
            var postUrl     = _appSettings.WallPostUrl(organization.ShortName, commentDto.PostId);
            var subject     = $"You have been mentioned in the post";
            var messageBody = _markdownConverter.ConvertToHtml(comment);

            foreach (var mentionedUser in mentionedUsers)
            {
                try
                {
                    if (mentionedUser.NotificationsSettings != null && !mentionedUser.NotificationsSettings.MentionEmailNotifications)
                    {
                        continue;
                    }

                    var newMentionTemplateViewModel = new NewMentionTemplateViewModel(
                        mentionedUser.FullName,
                        commentCreator.FullName,
                        postUrl,
                        userNotificationSettingsUrl,
                        messageBody);

                    var content = _mailTemplate.Generate(newMentionTemplateViewModel, EmailTemplateCacheKeys.NewMention);

                    var emailData = new EmailDto(mentionedUser.Email, subject, content);
                    _mailingService.SendEmail(emailData);
                }
                catch (Exception e)
                {
                    _logger.Debug(e.Message, e);
                }
            }
        }
Beispiel #2
0
        public void NotifyRejectedKudosLogSender(KudosLog kudosLog)
        {
            var emailRecipient = _usersDbSet.SingleOrDefault(user => user.Id == kudosLog.CreatedBy);

            if (emailRecipient == null)
            {
                return;
            }

            var organizationName            = GetOrganizationName(kudosLog.OrganizationId).ShortName;
            var subject                     = Resources.Models.Kudos.Kudos.RejectedKudosEmailSubject;
            var userNotificationSettingsUrl = _appSettings.UserNotificationSettingsUrl(organizationName);
            var kudosProfileUrl             = _appSettings.KudosProfileUrl(organizationName, kudosLog.CreatedBy);

            var emailTemplateViewModel = new KudosRejectedEmailTemplateViewModel(
                userNotificationSettingsUrl,
                kudosLog.Employee.FullName,
                kudosLog.Points,
                kudosLog.KudosTypeName,
                kudosLog.Comments,
                kudosLog.RejectionMessage,
                kudosProfileUrl);
            var body = _mailTemplate.Generate(emailTemplateViewModel, EmailTemplateCacheKeys.KudosRejected);

            _mailingService.SendEmail(new EmailDto(emailRecipient.Email, subject, body));
        }
Beispiel #3
0
        public void NotifyAboutNewPost(Post post, ApplicationUser postCreator)
        {
            var organization = _organizationService.GetOrganizationById(postCreator.OrganizationId);
            var wall         = _wallsDbSet.Single(w => w.Id == post.WallId);

            var destinationEmails           = _userService.GetWallUsersEmails(postCreator.Email, wall);
            var postLink                    = GetPostLink(wall.Type, wall.Id, organization.ShortName, post.Id);
            var authorPictureUrl            = _appSettings.PictureUrl(organization.ShortName, postCreator.PictureId);
            var userNotificationSettingsUrl = _appSettings.UserNotificationSettingsUrl(organization.ShortName);
            var subject = string.Format(Templates.NewWallPostEmailSubject, wall.Name, postCreator.FullName);
            var body    = _markdownConverter.ConvertToHtml(post.MessageBody);

            var emailTemplateViewModel = new NewWallPostEmailTemplateViewModel(
                GetWallTitle(wall),
                authorPictureUrl,
                postCreator.FullName,
                postLink,
                body,
                userNotificationSettingsUrl,
                GetActionButtonTitle(wall));
            var content = _mailTemplate.Generate(emailTemplateViewModel, EmailTemplateCacheKeys.NewWallPost);

            var emailData = new EmailDto(destinationEmails, subject, content);

            _mailingService.SendEmail(emailData);
        }
Beispiel #4
0
        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);
        }
Beispiel #6
0
 public async void SendMail()
 {
     await mailingService.SendEmail(new Mail()
     {
         Body = "Hello world!"
     }, "*****@*****.**");
 }
Beispiel #7
0
        public void SubmitTicket(UserAndOrganizationDTO userAndOrganization, SupportDto support)
        {
            var currentApplicationUser = _applicationUsers.Single(u => u.Id == userAndOrganization.UserId);

            var email = new EmailDto(currentApplicationUser.FullName, currentApplicationUser.Email, _applicationSettings.SupportEmail, $"{support.Type}: {support.Subject}", support.Message);

            _mailingService.SendEmail(email, true);
        }
Beispiel #8
0
        private void SendEmail(string userEmail, IEnumerable <Post> wallPosts, string organizationShortName)
        {
            var messageBody    = GetMessageBody(wallPosts, organizationShortName);
            var messageSubject = ConstBusinessLayer.ShroomsInfoEmailSubject;

            var emailDTO = new EmailDto(userEmail, messageSubject, messageBody);

            _emailService.SendEmail(emailDTO);
        }
Beispiel #9
0
 public void DoSomethingMore()
 {
     try
     {
     }
     catch (Exception exc)
     {
         _logger.LogError(exc.Message);
         _mailing.SendEmail("Error", exc.Message);
     }
 }
Beispiel #10
0
        private void SendBirthdayReminder(IEnumerable <ApplicationUser> employees, string organizationName)
        {
            var currentOrganization = _organizationsDbSet
                                      .First(name => name.ShortName == organizationName);

            var receivers = _roleService.GetAdministrationRoleEmails(currentOrganization.Id);
            var model     = new BirthdaysNotificationTemplateViewModel(GetFormattedEmployeesList(employees, organizationName, currentOrganization.ShortName), _appSettings.UserNotificationSettingsUrl(organizationName));
            var content   = _mailTemplate.Generate(model, EmailTemplateCacheKeys.BirthdaysNotification);
            var emailData = new EmailDto(receivers, Resources.Emails.Templates.BirthdaysNotificationEmailSubject, content);

            _mailingService.SendEmail(emailData);
        }
Beispiel #11
0
        public void SendConfirmedNotificationEmail(string userEmail, UserAndOrganizationDTO userAndOrg)
        {
            var organizationNameAndContent = _organizationDbSet
                                             .Where(organization => organization.Id == userAndOrg.OrganizationId)
                                             .Select(organization => new { organization.ShortName, organization.WelcomeEmail })
                                             .FirstOrDefault();

            if (organizationNameAndContent == null)
            {
                return;
            }

            var mainPageUrl     = _appSettings.ClientUrl;
            var userSettingsUrl = _appSettings.UserNotificationSettingsUrl(organizationNameAndContent.ShortName);
            var subject         = string.Format(Resources.Common.NewUserConfirmedNotificationEmailSubject);

            var emailTemplateViewModel = new UserConfirmationEmailTemplateViewModel(userSettingsUrl, mainPageUrl, organizationNameAndContent.WelcomeEmail);

            var body = _mailTemplate.Generate(emailTemplateViewModel, EmailTemplateCacheKeys.UserConfirmation);

            _mailingService.SendEmail(new EmailDto(userEmail, subject, body));
        }
Beispiel #12
0
        private void SendWallSubscriberEmails(NewlyCreatedPostDTO post, List <string> destinationEmails, ApplicationUser postCreator, Organization organization, DataLayer.EntityModels.Models.Multiwall.Wall wall)
        {
            var postLink                    = GetPostLink(post.WallType, post.WallId, organization.ShortName, post.Id);
            var authorPictureUrl            = _appSettings.PictureUrl(organization.ShortName, postCreator.PictureId);
            var userNotificationSettingsUrl = _appSettings.UserNotificationSettingsUrl(organization.ShortName);
            var subject = string.Format(Templates.NewWallPostEmailSubject, wall.Name, postCreator.FullName);
            var body    = _markdownConverter.ConvertToHtml(post.MessageBody);

            var emailTemplateViewModel = new NewWallPostEmailTemplateViewModel(
                GetWallTitle(wall),
                authorPictureUrl,
                postCreator.FullName,
                postLink,
                body,
                userNotificationSettingsUrl,
                GetActionButtonTitle(wall));
            var content = _mailTemplate.Generate(emailTemplateViewModel, EmailTemplateCacheKeys.NewWallPost);

            var emailData = new EmailDto(destinationEmails, subject, content);

            _mailingService.SendEmail(emailData);
        }
Beispiel #13
0
        public async Task <IValidationState> RegisterUser(UserRegistrationModel registrationModel)
        {
            ValidationState validationState = new ValidationState();

            if (registrationModel == null)
            {
                validationState.AddError("Invalid data.", "Data");
                return(validationState);
            }

            if (string.IsNullOrEmpty(registrationModel.Username))
            {
                validationState.AddError("Invalid username.", "Username");
                return(validationState);
            }

            if (registrationModel.Password.Length < 6)
            {
                validationState.AddError("Invalid password.", "Password");
                return(validationState);
            }

            var existingUser = _context.Users.SingleOrDefault(x => x.Username == registrationModel.Username);

            if (existingUser != null)
            {
                validationState.AddError("User already exists, choose another username.", "Username");
                return(validationState);
            }

            var newUser = new User()
            {
                Username = registrationModel.Username,
                Regdate  = DateTime.Now,
                Password = registrationModel.Password,
                Email    = registrationModel.Email
            };

            var registrationCode = "aaabbbccc";

            newUser.AddCode(registrationCode);

            var mail = await _mailProvider.GetRegistrationMailBody("http://localhost:8080/#/");

            await _mailingService.SendEmail(mail, newUser.Email);

            _context.Users.Add(newUser);
            _context.SaveChanges();

            return(validationState);
        }
        public void SendEmail(TakenBookDTO takenBook)
        {
            var organizationName = _organizationsDbSet
                                   .Where(organization => organization.Id == takenBook.OrganizationId)
                                   .Select(organization => organization.ShortName)
                                   .FirstOrDefault();

            var userEmail = _usersDbSet
                            .Where(u => u.Id == takenBook.UserId)
                            .Select(u => u.Email)
                            .First();

            var subject = Resources.Models.Books.Books.EmailSubject;
            var userNotificationSettingsUrl = _appSettings.UserNotificationSettingsUrl(organizationName);
            var bookUrl = _appSettings.BookUrl(organizationName, takenBook.BookOfficeId, takenBook.OfficeId);

            var emailTemplateViewModel = new BookTakenEmailTemplateViewModel(userNotificationSettingsUrl, takenBook.Title, takenBook.Author, bookUrl);
            var body = _mailTemplate.Generate(emailTemplateViewModel, EmailTemplateCacheKeys.BookTaken);

            _mailingService.SendEmail(new EmailDto(userEmail, subject, body));
        }