Esempio n. 1
0
        public void SendOrganizationInviteNotification(InviteNotification notification,
                                                       OrganizationInviteCommand command)
        {
            var objectName = string.Empty;
            var customText = string.Empty;
            var userRole   = string.Empty;

            using (var session = noSqlSessionFactory())
            {
                var org =
                    session.GetAll <Data.MongoDB.Organization>().Where(o => o.Id == command.OrganizationId).Select(
                        o => new { o.Name, o.CustomInvitationText }).SingleOrDefault();
                objectName = org.Name;
                customText = org.CustomInvitationText;
            }

            using (var session = actionsSessionFactory.CreateContext())
            {
                var member =
                    session.UserInterestingOrganizations.SingleOrDefault(
                        u => u.OrganizationId == command.OrganizationId && u.UserId == command.UserId);

                userRole = member.Role;
            }

            SendInviteNotification(notification, (int)NotificationTypes.OrganizationInvite, command.UserFullName,
                                   command.UserLink, objectName, command.OrganizationLink, command.Email, userRole, customText,
                                   u => u.OrganizationId == command.OrganizationId);
        }
Esempio n. 2
0
        public void SendProjectInviteNotification(InviteNotification notification, ProjectInviteCommand command)
        {
            var objectName = string.Empty;

            using (var session = noSqlSessionFactory())
            {
                objectName =
                    session.GetAll <Data.MongoDB.Idea>().Where(o => o.ProjectId == command.ProjectId).Select(
                        o => o.Subject).SingleOrDefault();
            }

            SendInviteNotification(notification, (int)NotificationTypes.ProjectInvite, command.UserFullName, command.UserLink, objectName, command.ProjectLink, command.Email, string.Empty, string.Empty, u => u.ProjectId == command.ProjectId);
        }
Esempio n. 3
0
        private void SendInviteNotification(InviteNotification notification, int notificationId, string userFullName, string userLink, string objectName, string objectLink, string email, string role, string customText, Func <UserInvitation, bool> predicate)
        {
            notification.UserFullName = userFullName;
            notification.UserLink     = userLink;
            notification.ObjectName   = objectName;
            notification.ObjectLink   = objectLink;
            var not = GetNotification(notificationId);

            notification.MessageTemplate = not.Message;
            notification.Subject         = not.Subject;
            notification.Exception       = null;
            notification.UserRole        = role;
            notification.CustomText      = customText;

            notification.To = email;

            using (var session = usersSessionFactory.CreateContext(true))
            {
                var inv = session.UserInvitations.Where(u => u.UserEmail == email).Where(predicate).SingleOrDefault();

                try
                {
                    var success = notification.Execute();

                    if (inv != null)
                    {
                        if (success)
                        {
                            inv.InvitationSent++;
                        }
                        else if (notification.Exception != null)
                        {
                            inv.Message = notification.Exception.Message;
                        }
                    }
                }
                catch (Exception e)
                {
                    if (inv != null)
                    {
                        inv.Message = e.Message;
                    }
                }
            }
        }
 public ProjectInviteCommandHandler(InviteNotification notification)
 {
     this.notification = notification;
 }
Esempio n. 5
0
 public OrganizationInviteCommandHandler(InviteNotification notification)
 {
     this.notification = notification;
 }