コード例 #1
0
        public ActionResult Communications(Guid id)
        {
            var organisation = _organisationsQuery.GetOrganisation(id);

            if (organisation == null)
            {
                return(NotFound("organisation", "id", id));
            }

            var settings   = _settingsQuery.GetSettings(organisation.Id);
            var categories = _settingsQuery.GetCategories(UserType.Employer);

            return(View(GetCommunicationsModel(organisation, settings, categories)));
        }
コード例 #2
0
        private void UpdateSuggestedJobs(Guid memberId, bool sendSuggestedJobs)
        {
            try
            {
                var category  = _settingsQuery.GetCategory("SuggestedJobs");
                var settings  = _settingsQuery.GetSettings(memberId);
                var frequency = Frequency.Never;

                if (settings != null && settings.CategorySettings != null)
                {
                    var setting = settings.CategorySettings.FirstOrDefault(c => c.CategoryId == category.Id);

                    if (setting != null && setting.Frequency.HasValue)
                    {
                        frequency = setting.Frequency.Value;
                    }
                }

                var currentlySending = frequency != Frequency.Never;

                if (!sendSuggestedJobs && currentlySending)
                {
                    _settingsCommand.SetFrequency(memberId, category.Id, Frequency.Never);
                }
                else if (sendSuggestedJobs && !currentlySending)
                {
                    _settingsCommand.SetFrequency(memberId, category.Id, Frequency.Daily);
                }
            }
            catch (UserException ex)
            {
                ModelState.AddModelError(ex, new StandardErrorHandler());
            }
        }
コード例 #3
0
ファイル: DesiredJob.ascx.cs プロジェクト: formist/LinkMe
        private bool GetSuggestedJobSetting(Guid memberId)
        {
            var category = _settingsQuery.GetCategory("SuggestedJobs");
            var setting = _settingsQuery.GetSettings(memberId).CategorySettings.FirstOrDefault(c => c.CategoryId == category.Id);

            return (setting.Frequency != Frequency.Never);
        }
コード例 #4
0
        public ActionResult Settings()
        {
            var member = CurrentMember;
            var primaryEmailAddress   = member.GetPrimaryEmailAddress();
            var secondaryEmailAddress = member.GetSecondaryEmailAddress();

            var settingsModel = new SettingsModel
            {
                CanEditContactDetails = CanEditContactDetails(),
                FirstName             = member.FirstName,
                LastName              = member.LastName,
                EmailAddress          = primaryEmailAddress == null ? null : primaryEmailAddress.Address,
                SecondaryEmailAddress = secondaryEmailAddress == null ? null : secondaryEmailAddress.Address,
            };

            UpdateCategories(settingsModel, _settingsQuery.GetSettings(User.Id().Value));

            return(View(settingsModel));
        }
コード例 #5
0
        public void TestUnsubscribe()
        {
            // Create the member.

            var member   = CreateMember();
            var category = GetCategory();

            // Check the current settings.

            var settings = _settingsQuery.GetSettings(member.Id);

            Assert.IsFalse(settings.CategorySettings.Any(c => c.CategoryId == category.Id));
            Assert.IsTrue(category.DefaultFrequency != Frequency.Never);

            // Get the page.

            Get(GetUnsubscribeUrl(member.Id, category.Name));
            Assert.IsTrue(_unsubscribeButton.IsVisible);
            AssertPageContains("Please confirm that you would like to unsubscribe");

            // Unsubscribe.

            _unsubscribeButton.Click();
            Assert.IsFalse(_unsubscribeButton.IsVisible);
            AssertPageContains("You have now been unsubscribed");

            // Check the current settings.

            settings = _settingsQuery.GetSettings(member.Id);
            var categorySettings = settings.CategorySettings.SingleOrDefault(c => c.CategoryId == category.Id);

            Assert.AreEqual(Frequency.Never, categorySettings.Frequency);

            // Login and confirm redirect.

            _loginIdTextBox.Text  = member.GetLoginId();
            _passwordTextBox.Text = member.GetPassword();
            _loginButton.Click();
            AssertUrl(_settingsUrl);
        }
コード例 #6
0
        public ActionResult Settings()
        {
            var employer = CurrentEmployer;

            var credentials = _loginCredentialsQuery.GetCredentials(employer.Id);

            var jobPoster = _jobPostersQuery.GetJobPoster(employer.Id) ?? new JobPoster {
                Id = employer.Id
            };
            var nonMemberSettings = _nonMemberSettingsQuery.GetNonMemberSettings(employer.EmailAddress.Address);

            var settings = _settingsQuery.GetSettings(employer.Id);
            var employerUpdateCategory = (from c in _settingsQuery.GetCategories(UserType.Employer) where c.Name == "EmployerUpdate" select c).Single();
            var campaignCategory       = (from c in _settingsQuery.GetCategories(UserType.Employer) where c.Name == "Campaign" select c).Single();

            var model = new SettingsModel
            {
                FirstName               = employer.FirstName,
                LastName                = employer.LastName,
                OrganisationName        = employer.Organisation.Name,
                CanEditOrganisationName = !employer.Organisation.IsVerified,
                Role                       = employer.SubRole,
                JobTitle                   = employer.JobTitle,
                EmailAddress               = employer.EmailAddress.Address,
                PhoneNumber                = employer.PhoneNumber == null ? null : employer.PhoneNumber.Number,
                IndustryIds                = employer.Industries == null ? new List <Guid>() : employer.Industries.Select(i => i.Id).ToList(),
                Industries                 = _industriesQuery.GetIndustries(),
                HasLoginCredentials        = credentials != null,
                LoginId                    = credentials == null ? null : credentials.LoginId,
                UseLinkedInProfile         = _linkedInQuery.GetProfile(employer.Id) != null,
                Allocations                = GetAllocations(employer),
                ShowSuggestedCandidates    = jobPoster.ShowSuggestedCandidates,
                SendSuggestedCandidates    = jobPoster.SendSuggestedCandidates,
                ReceiveSuggestedCandidates = nonMemberSettings == null || !nonMemberSettings.SuppressSuggestedCandidatesEmails,
                EmailEmployerUpdate        = EmailCategory(employerUpdateCategory, settings),
                EmailCampaign              = EmailCategory(campaignCategory, settings),
            };

            return(View(model));
        }
コード例 #7
0
        public void TestEmployerUpdate()
        {
            var employer = CreateEmployer(0);

            LogIn(employer);
            Get(_settingsUrl);

            AssertCategory("EmployerUpdate", null, _settingsQuery.GetSettings(employer.Id));
            Assert.AreEqual(true, _emailEmployerUpdateCheckBox.IsChecked);

            // Turn it off.

            _emailEmployerUpdateCheckBox.IsChecked = false;
            _saveButton.Click();

            AssertCategory("EmployerUpdate", Frequency.Never, _settingsQuery.GetSettings(employer.Id));
            AssertUrlWithoutQuery(LoggedInEmployerHomeUrl);
            Get(_settingsUrl);
            Assert.AreEqual(false, _emailEmployerUpdateCheckBox.IsChecked);

            // Turn it on again.

            _emailEmployerUpdateCheckBox.IsChecked = true;
            _saveButton.Click();

            AssertCategory("EmployerUpdate", Frequency.Immediately, _settingsQuery.GetSettings(employer.Id));
            AssertUrlWithoutQuery(LoggedInEmployerHomeUrl);
            Get(_settingsUrl);
            Assert.AreEqual(true, _emailEmployerUpdateCheckBox.IsChecked);
        }
コード例 #8
0
ファイル: UserEmailsQuery.cs プロジェクト: formist/LinkMe
        private EffectiveRecipientSettings GetEffectiveEmployerSettings(Guid employerId, Category category)
        {
            var hierarchyPath = _recruitersQuery.GetOrganisationHierarchyPath(employerId);

            foreach (var organisationId in hierarchyPath.Skip(1))
            {
                var settings = _settingsQuery.GetSettings(organisationId);
                if (settings != null)
                {
                    var categorySettings = (from s in settings.CategorySettings where s.CategoryId == category.Id select s).SingleOrDefault();
                    if (categorySettings != null && categorySettings.Frequency == Frequency.Never)
                    {
                        return new EffectiveRecipientSettings {
                                   Timing = category.Timing, Frequency = Frequency.Never, LastSentTime = null
                        }
                    }
                    ;
                }
            }

            return(null);
        }
コード例 #9
0
        private void UpdateSuggestedJobs(Guid memberId, bool sendSuggestedJobs)
        {
            var category = _settingsQuery.GetCategory("SuggestedJobs");
            var setting  = _settingsQuery.GetSettings(memberId).CategorySettings.Where(c => c.CategoryId == category.Id).FirstOrDefault();

            var currentlySending = setting.Frequency != Frequency.Never;

            if (!sendSuggestedJobs && currentlySending)
            {
                _settingsCommand.SetFrequency(memberId, category.Id, Frequency.Never);
            }
            else if (sendSuggestedJobs && !currentlySending)
            {
                _settingsCommand.SetFrequency(memberId, category.Id, Frequency.Daily);
            }
        }
コード例 #10
0
        public void TestDefault()
        {
            var administrator = _administratorAccountsCommand.CreateTestAdministrator(1);
            var organisation  = _organisationsCommand.CreateTestVerifiedOrganisation(1);

            LogIn(administrator);
            Get(GetCommunicationsUrl(organisation));

            AssertCategory("EmployerUpdate", null, _settingsQuery.GetSettings(organisation.Id));
            AssertCategory("Campaign", null, _settingsQuery.GetSettings(organisation.Id));
            AssertCategory("PartnerNotification", null, _settingsQuery.GetSettings(organisation.Id));

            Assert.AreEqual(true, _employerUpdateCheckBox.IsChecked);
            Assert.AreEqual(true, _campaignCheckBox.IsChecked);
        }
コード例 #11
0
        private void AssertSuggestedJobs(bool expectedSendSuggestedJobs, Guid memberId)
        {
            var category  = _settingsQuery.GetCategory("SuggestedJobs");
            var frequency = Frequency.Never;
            var settings  = _settingsQuery.GetSettings(memberId);

            if (settings != null)
            {
                var setting = settings.CategorySettings.Where(c => c.CategoryId == category.Id).FirstOrDefault();

                if (setting != null && setting.Frequency.HasValue)
                {
                    frequency = setting.Frequency.Value;
                }
            }

            Assert.AreEqual(expectedSendSuggestedJobs, frequency != Frequency.Never);
        }
コード例 #12
0
ファイル: ProfilesController.cs プロジェクト: formist/LinkMe
        private bool GetSuggestedJobsEmailSetting(Guid memberId)
        {
            var category  = _settingsQuery.GetCategory("SuggestedJobs");
            var settings  = _settingsQuery.GetSettings(memberId);
            var frequency = Frequency.Never;

            if (settings != null && settings.CategorySettings != null)
            {
                var setting = settings.CategorySettings.FirstOrDefault(c => c.CategoryId == category.Id);

                if (setting != null && setting.Frequency.HasValue)
                {
                    frequency = setting.Frequency.Value;
                }
            }

            return(frequency != Frequency.Never);
        }
コード例 #13
0
ファイル: EmailsTests.cs プロジェクト: formist/LinkMe
        protected void AssertSettings(IHasId <Guid> user, Category category, Frequency frequency)
        {
            var settings = _settingsQuery.GetSettings(user.Id);

            if (settings == null)
            {
                Assert.AreEqual(category.DefaultFrequency, frequency);
            }
            else
            {
                var categorySettings = settings.CategorySettings.SingleOrDefault(c => c.CategoryId == category.Id);
                if (categorySettings != null)
                {
                    Assert.AreEqual(frequency, categorySettings.Frequency);
                }
                else
                {
                    Assert.AreEqual(category.DefaultFrequency, frequency);
                }
            }
        }
コード例 #14
0
        public void TestDefaults()
        {
            // By default some settings may be set up for the user so remove those first.

            var index  = 0;
            var member = _memberAccountsCommand.CreateTestMember(++index);

            _settingsCommand.DeleteSettings(member.Id);

            LogIn(member);
            Get(_settingsUrl);

            // The user's settings should reflect the defaults for the categories.

            var categories = _settingsQuery.GetCategories(UserType.Member);

            AssertCategories(categories);
            AssertSettings(categories, c => c.Timing, c => c.DefaultFrequency, c => c.Name);

            // The user's settings should also reflect the settings for the user.

            var settings = _settingsQuery.GetSettings(member.Id);

            AssertCategorySettings(categories, settings);

            // Create a member with a changed regular category.

            member   = _memberAccountsCommand.CreateTestMember(++index);
            settings = ChangeCategorySettings((from c in categories where c.Timing == Timing.Periodic select c).First().Id, Frequency.Monthly, member.Id);

            LogOut();
            LogIn(member);
            Get(_settingsUrl);
            AssertCategories(categories);
            AssertCategorySettings(categories, settings);

            // Create a member with a changed notification category.

            member   = _memberAccountsCommand.CreateTestMember(++index);
            settings = ChangeCategorySettings((from c in categories where c.Timing == Timing.Notification select c).First().Id, Frequency.Never, member.Id);

            LogOut();
            LogIn(member);
            Get(_settingsUrl);
            AssertCategories(categories);
            AssertCategorySettings(categories, settings);

            // Create a member with changed categories.

            member = _memberAccountsCommand.CreateTestMember(++index);
            ChangeCategorySettings(categories.First(c => c.Timing == Timing.Periodic).Id, Frequency.Daily, member.Id);
            settings = ChangeCategorySettings((from c in categories where c.Timing == Timing.Notification select c).Last().Id, Frequency.Never, member.Id);

            LogOut();
            LogIn(member);
            Get(_settingsUrl);
            AssertCategories(categories);
            AssertCategorySettings(categories, settings);

            // Change it back.

            settings = ChangeCategorySettings((from c in categories where c.Timing == Timing.Notification select c).Last().Id, Frequency.Immediately, member.Id);

            LogOut();
            LogIn(member);
            Get(_settingsUrl);
            AssertCategories(categories);
            AssertCategorySettings(categories, settings);
        }