private static List <Notification> SendMessageAndLogNotification(Project project,
                                                                         MailMessage mailMessage,
                                                                         List <string> emailsToSendTo,
                                                                         List <string> emailsToReplyTo,
                                                                         List <string> emailsToCc,
                                                                         NotificationType notificationType)
        {
            var submitterPerson      = project.ProposingPerson;
            var primaryContactPerson = project.PrimaryContactPerson;

            var notificationPeople = new List <Person> {
                submitterPerson
            };

            if (primaryContactPerson != null && submitterPerson.PersonID != primaryContactPerson.PersonID)
            {
                notificationPeople.Add(primaryContactPerson);
            }

            var contactsWhoCanManageProject = project.GetContactsWhoCanManageProject();

            foreach (var contact in contactsWhoCanManageProject)
            {
                if (contact.PersonID != submitterPerson.PersonID && (primaryContactPerson == null || primaryContactPerson.PersonID != contact.PersonID))
                {
                    notificationPeople.Add(contact);
                }
            }

            NotificationModelExtensions.SendMessage(mailMessage, emailsToSendTo, emailsToReplyTo, emailsToCc, MultiTenantHelpers.GetToolDisplayName());
            var notifications = new List <Notification>();

            foreach (var notificationPerson in notificationPeople)
            {
                var notification = new Notification(notificationType, notificationPerson, DateTime.Now);
                notification.NotificationProjects = new List <Project> {
                    project
                }.Select(p => new NotificationProject(notification, p)).ToList();
                notifications.Add(notification);
            }
            return(notifications);
        }
        private static void SendMessageAndLogNotificationForProjectUpdateTransition(ProjectUpdateBatch projectUpdateBatch,
                                                                                    MailMessage mailMessage,
                                                                                    List <string> emailsToSendTo,
                                                                                    List <string> emailsToReplyTo,
                                                                                    List <string> emailsToCc, NotificationType notificationType)
        {
            var latestProjectUpdateHistorySubmitted = projectUpdateBatch.GetLatestProjectUpdateHistorySubmitted();
            var submitterPerson      = latestProjectUpdateHistorySubmitted.UpdatePerson;
            var primaryContactPerson = projectUpdateBatch.Project.GetPrimaryContact();

            var notificationPeople = new List <Person> {
                submitterPerson
            };

            if (primaryContactPerson != null && submitterPerson.PersonID != primaryContactPerson.PersonID)
            {
                notificationPeople.Add(primaryContactPerson);
            }

            var contactsWhoCanManageProject = projectUpdateBatch.Project.GetContactsWhoCanManageProject();

            foreach (var contact in contactsWhoCanManageProject)
            {
                if (contact.PersonID != submitterPerson.PersonID && (primaryContactPerson == null || primaryContactPerson.PersonID != contact.PersonID))
                {
                    notificationPeople.Add(contact);
                }
            }

            NotificationModelExtensions.SendMessageAndLogNotification(mailMessage,
                                                                      emailsToSendTo,
                                                                      emailsToReplyTo,
                                                                      emailsToCc,
                                                                      notificationPeople,
                                                                      DateTime.Now,
                                                                      new List <Project> {
                projectUpdateBatch.Project
            },
                                                                      notificationType,
                                                                      MultiTenantHelpers.GetToolDisplayName());
        }