public void TestFinsia()
        {
            _activeCommunity = ActiveCommunity.Finsia;

            // Create an employer.

            var employer = _employerAccountsCommand.CreateTestEmployer(0, _organisationsCommand.CreateTestOrganisation(0));

            // Create a member.

            var community   = TestCommunity.Finsia.CreateTestCommunity(_communitiesCommand, _verticalsCommand, _contentEngine);
            var member      = _memberAccountsCommand.CreateTestMember(0, community.Id);
            var representee = _memberAccountsCommand.CreateTestMember(1);

            var view          = new ProfessionalView(member, null, ProfessionalContactDegree.Contacted, true, false);
            var communication = new RepresentativeContactCandidateEmail(view, NewEmployerEmail, employer, representee, Subject, Content);

            _emailsCommand.TrySend(communication);

            // Check.

            var email = _emailServer.AssertEmailSent();

            email.AssertAddresses(new EmailRecipient(NewEmployerEmail, employer.FullName), Return, member);
            email.AssertSubject(Subject);
            email.AssertViewChecks(MediaTypeNames.Text.Html);
            email.AssertView(MediaTypeNames.Text.Html, GetBody(communication, member, GetContent(member, representee, employer, Content)));
            email.AssertNoAttachments();
            AssertCompatibleAddresses(email);
        }
        public void TestNoAccess()
        {
            // Create an employer.

            var employer = _employerAccountsCommand.CreateTestEmployer(0, _organisationsCommand.CreateTestOrganisation(0));

            // Create a member.

            var member      = _memberAccountsCommand.CreateTestMember(0);
            var representee = _memberAccountsCommand.CreateTestMember(1);

            // Send.

            var view            = new ProfessionalView(member, 0, ProfessionalContactDegree.NotContacted, false, false);
            var representeeView = new ProfessionalView(representee, 0, ProfessionalContactDegree.NotContacted, false, false);
            var communication   = new RepresentativeContactCandidateEmail(view, null, employer, representeeView, Subject, Content);

            _emailsCommand.TrySend(communication);

            // Check.

            var email = _emailServer.AssertEmailSent();

            email.AssertAddresses(employer, Return, member);
            email.AssertSubject(Subject);
            email.AssertViewChecks(MediaTypeNames.Text.Html);
            email.AssertView(MediaTypeNames.Text.Html, GetBody(communication, member, GetContent(member, representee, employer, Content)));
            email.AssertNoAttachments();
            AssertCompatibleAddresses(email);
        }
        public void TestAutoPeople()
        {
            // Create an employer.

            var employer = _employerAccountsCommand.CreateTestEmployer(0, _organisationsCommand.CreateTestOrganisation(0));

            // Create a member.

            var member      = _memberAccountsCommand.CreateTestMember(0);
            var representee = _memberAccountsCommand.CreateTestMember(1);

            // Send in the context of Autopeople. Should still be a standard email because the member is not a member of Autopeople.

            Community community = TestCommunity.Autopeople.CreateTestCommunity(_communitiesCommand, _verticalsCommand, _contentEngine);

            ActivityContext.Current.Community.Set(community);

            var view          = new ProfessionalView(member, null, ProfessionalContactDegree.Contacted, true, false);
            var communication = new RepresentativeContactCandidateEmail(view, NewEmployerEmail, employer, representee, Subject, Content);

            _emailsCommand.TrySend(communication);

            // Check.

            var email = _emailServer.AssertEmailSent();

            email.AssertAddresses(new EmailRecipient(NewEmployerEmail, employer.FullName), Return, member);
            email.AssertSubject(Subject);
            email.AssertViewChecks(MediaTypeNames.Text.Html);
            email.AssertView(MediaTypeNames.Text.Html, GetBody(communication, member, GetContent(member, representee, employer, Content)));
            email.AssertNoAttachments();
            AssertCompatibleAddresses(email);
        }
Esempio n. 4
0
        void IMessagesHandler.OnMessageSent(Guid fromId, Guid toId, Guid?representativeId, MemberMessage message)
        {
            var member   = _membersQuery.GetMember(toId);
            var employer = _employersQuery.GetEmployer(fromId);

            IList <FileReference> fileReferences = null;

            if (message.AttachmentIds != null && message.AttachmentIds.Count > 0)
            {
                var messageAttachments = _employerMemberContactsQuery.GetMessageAttachments(employer, message.AttachmentIds);
                fileReferences = _filesQuery.GetFileReferences(from a in messageAttachments select a.FileReferenceId, new Range());
            }

            // Create the email to send to the member and send it.

            TemplateEmail email;

            if (representativeId == null)
            {
                email = new ContactCandidateEmail(member, message.From, employer, message.Subject, GetMemberBody(message.Body, member));
            }
            else
            {
                var representative = _membersQuery.GetMember(representativeId.Value);
                email = new RepresentativeContactCandidateEmail(representative, message.From, employer, member, message.Subject, GetMemberBody(message.Body, member));
            }

            AddAttachments(email, fileReferences);
            _emailsCommand.TrySend(email);

            // Create the email to the employer and send it.

            if (message.SendCopy)
            {
                // Need the view.

                var view = _employerMemberViewsQuery.GetProfessionalView(employer, member);
                var confirmationEmail = new EmployerContactCandidateConfirmationEmail(message.From, employer, member.Id, view.GetFullNameDisplayText(), message.Subject, GetEmployerBody(message.Body, view));
                AddAttachments(confirmationEmail, fileReferences);
                _emailsCommand.TrySend(confirmationEmail);
            }
        }