Ejemplo n.º 1
0
        private void CreateEmployer(int index, DateTime createdTime)
        {
            var employer = CreateEmployer(index);

            employer.CreatedTime = createdTime;
            _employerAccountsCommand.UpdateEmployer(employer);
        }
Ejemplo n.º 2
0
        public void TestCompanyNameChanged()
        {
            const string verifiedCompanyName = "Verified Company";

            var employer = CreateEmployer(0);

            LogIn(employer);
            Get(_settingsUrl);

            // Update the unverified company name

            Assert.IsFalse(_organisationNameTextBox.IsReadOnly);
            Assert.AreEqual(employer.Organisation.FullName, _organisationNameTextBox.Text);
            _organisationNameTextBox.Text = NewCompanyName;
            _saveButton.Click();

            AssertUrlWithoutQuery(LoggedInEmployerHomeUrl);
            LogOut();

            // Check that the update succeeded.

            var updatedEmployer = _employersQuery.GetEmployer(employer.Id);

            Assert.AreEqual(NewCompanyName, updatedEmployer.Organisation.FullName);

            // Make a verified company.

            var admin        = _administratorsCommand.CreateTestAdministrator(0);
            var organisation = new VerifiedOrganisation {
                Name = verifiedCompanyName, VerifiedById = admin.Id, AccountManagerId = admin.Id
            };

            _organisationsCommand.CreateOrganisation(organisation);
            employer.Organisation = organisation;
            _employerAccountsCommand.UpdateEmployer(employer);

            LogIn(employer);
            Get(_settingsUrl);

            // Try to change name again.

            Assert.AreEqual(verifiedCompanyName, _organisationNameTextBox.Text);
            Assert.IsTrue(_organisationNameTextBox.IsReadOnly);
            _organisationNameTextBox.Text = NewCompanyName;
            _saveButton.Click();

            // Check that the update was NOT made.

            updatedEmployer = _employersQuery.GetEmployer(employer.Id);
            Assert.AreEqual(verifiedCompanyName, updatedEmployer.Organisation.FullName);

            // Assert page.

            AssertUrlWithoutQuery(LoggedInEmployerHomeUrl);
            Get(_settingsUrl);
            Assert.AreEqual(verifiedCompanyName, _organisationNameTextBox.Text);
        }
Ejemplo n.º 3
0
        public void TestEnabledDisabled()
        {
            // Create some employers.

            var administrator = _administratorAccountsCommand.CreateTestAdministrator(1);
            var organisation  = _organisationsCommand.CreateTestVerifiedOrganisation(1, null, administrator.Id);

            var employers = new Employer[10];

            for (var index = 0; index < 10; ++index)
            {
                employers[index] = _employerAccountsCommand.CreateTestEmployer(index, organisation);
            }
            for (var index = 0; index < 4; ++index)
            {
                employers[index].IsEnabled = false;
                _employerAccountsCommand.UpdateEmployer(employers[index]);
            }

            LogIn(administrator);
            Get(GetSearchEmployersUrl());

            Assert.AreEqual(true, _isEnabledCheckBox.IsChecked);
            Assert.AreEqual(true, _isDisabledCheckBox.IsChecked);

            // All.

            _searchButton.Click();
            AssertResults(10);

            // Enabled.

            _isEnabledCheckBox.IsChecked  = true;
            _isDisabledCheckBox.IsChecked = false;
            _searchButton.Click();
            AssertResults(6);

            // Disabled.

            _isEnabledCheckBox.IsChecked  = false;
            _isDisabledCheckBox.IsChecked = true;
            _searchButton.Click();
            AssertResults(4);

            // None.

            _isEnabledCheckBox.IsChecked  = false;
            _isDisabledCheckBox.IsChecked = false;
            _searchButton.Click();
            AssertResults(0);
        }
Ejemplo n.º 4
0
        public void TestEnable()
        {
            // Create the employer.

            var administrator = _administratorAccountsCommand.CreateTestAdministrator(1);
            var employer      = _employerAccountsCommand.CreateTestEmployer(1, _organisationsCommand.CreateTestOrganisation(0));

            employer.IsEnabled = false;
            _employerAccountsCommand.UpdateEmployer(employer);

            LogIn(employer);
            AssertPath(_contactUsUrl);

            LogIn(administrator);
            Get(GetEmployerUrl(employer));

            // Enable the User.

            _enableButton.Click();

            // Check the user details.

            employer.IsEnabled = true;
            AssertVisibility(employer);
            AssertEmployer(employer, employer.GetLoginId());

            // Check the user login.

            LogOut();
            LogIn(employer);
            AssertUrl(LoggedInEmployerHomeUrl);
        }
Ejemplo n.º 5
0
        private Employer CreateEmployer(int index)
        {
            var employer = _employerAccountsCommand.CreateTestEmployer(index, _organisationsCommand.CreateTestOrganisation(0));

            employer.JobTitle = "Archeologist";
            _employerAccountsCommand.UpdateEmployer(employer);
            return(employer);
        }
Ejemplo n.º 6
0
        private Employer[] CreateEmployers(int start, int count, IOrganisation organisation)
        {
            var employers = new Employer[count];

            for (var index = start; index < start + count; ++index)
            {
                var employer = _employerAccountsCommand.CreateTestEmployer(index, organisation);
                if ((index % 2 == 1))
                {
                    employer.IsEnabled = false;
                    _employerAccountsCommand.UpdateEmployer(employer);
                }

                employers[index - start] = employer;
            }

            return(employers);
        }
Ejemplo n.º 7
0
        public ActionResult Edit(Guid id, string firstName, string lastName, string emailAddress, string phoneNumber, string organisationName, string loginId)
        {
            Employer         employer    = null;
            LoginCredentials credentials = null;

            try
            {
                employer = _employersQuery.GetEmployer(id);
                if (employer == null)
                {
                    return(NotFound("employer", "id", id));
                }

                credentials = _loginCredentialsQuery.GetCredentials(employer.Id);
                if (credentials == null)
                {
                    return(NotFound("employer", "id", id));
                }

                // Update the employer.

                employer.FirstName    = firstName;
                employer.LastName     = lastName;
                employer.EmailAddress = string.IsNullOrEmpty(emailAddress) ? null : new EmailAddress {
                    Address = emailAddress
                };
                employer.PhoneNumber = _phoneNumbersQuery.GetPhoneNumber(phoneNumber, ActivityContext.Location.Country);

                // Update the organisation but only for verified organisations.

                if (employer.Organisation.IsVerified && organisationName != employer.Organisation.FullName)
                {
                    employer.Organisation = _organisationsQuery.GetVerifiedOrganisation(organisationName);
                }

                _employerAccountsCommand.UpdateEmployer(employer);

                // Update the credentials.

                credentials.LoginId = loginId;
                _loginCredentialsCommand.UpdateCredentials(employer.Id, credentials, User.Id().Value);
            }
            catch (UserException ex)
            {
                ModelState.AddModelError(ex, new StandardErrorHandler());
            }

            return(View(new UserModel <IEmployer, EmployerLoginModel>
            {
                User = employer,
                UserLogin = new EmployerLoginModel {
                    LoginId = credentials == null ? null : credentials.LoginId
                },
            }));
        }
Ejemplo n.º 8
0
        public void TestEnabledOnly()
        {
            var employer1 = _employerAccountsCommand.CreateTestEmployer(1, _organisationsCommand.CreateTestOrganisation(0));
            var employer2 = _employerAccountsCommand.CreateTestEmployer(2, _organisationsCommand.CreateTestOrganisation(0));
            var employer3 = _employerAccountsCommand.CreateTestEmployer(3, _organisationsCommand.CreateTestOrganisation(0));

            employer1.IsEnabled = false;
            _employerAccountsCommand.UpdateEmployer(employer1);

            var criteria = new AdministrativeEmployerSearchCriteria
            {
                IsEnabled  = true,
                IsDisabled = false
            };
            var employers = _executeEmployerSearchCommand.Search(criteria);

            Assert.AreEqual(2, employers.Count);
            AssertEmployer(employer2, employers[0]);
            AssertEmployer(employer3, employers[1]);
        }
Ejemplo n.º 9
0
        private Employer CreateEmployer(int index, EmployerSubRole subRole)
        {
            var employer = _employerAccountsCommand.CreateTestEmployer(index, _organisationsCommand.CreateTestOrganisation(index));

            if (employer.SubRole != subRole)
            {
                employer.SubRole = subRole;
                _employerAccountsCommand.UpdateEmployer(employer);
            }

            return(employer);
        }
Ejemplo n.º 10
0
        public void TestGetNewEmployers()
        {
            var employer1 = _employerAccountsCommand.CreateTestEmployer(1, _organisationsCommand.CreateTestOrganisation(0));

            employer1.CreatedTime = DateTime.Now.AddDays(-2);
            _employerAccountsCommand.UpdateEmployer(employer1);

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

            employer2.CreatedTime = DateTime.Now.AddDays(-1);
            _employerAccountsCommand.UpdateEmployer(employer2);

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

            employer3.CreatedTime = DateTime.Now.AddDays(-3);
            _employerAccountsCommand.UpdateEmployer(employer3);

            var recruiter4 = _employerAccountsCommand.CreateTestRecruiter(4, _organisationsCommand.CreateTestOrganisation(0));

            recruiter4.CreatedTime = DateTime.Now.AddDays(-1);
            _employerAccountsCommand.UpdateEmployer(recruiter4);

            var recruiter5 = _employerAccountsCommand.CreateTestRecruiter(5, _organisationsCommand.CreateTestOrganisation(0));

            recruiter5.CreatedTime = DateTime.Now.AddDays(0);
            _employerAccountsCommand.UpdateEmployer(recruiter5);

            var recruiter6 = _employerAccountsCommand.CreateTestRecruiter(6, _organisationsCommand.CreateTestOrganisation(0));

            recruiter6.CreatedTime = DateTime.Now.AddDays(-4);
            _employerAccountsCommand.UpdateEmployer(recruiter6);
        }
Ejemplo n.º 11
0
        protected Employer CreateEmployer(string email, string userId)
        {
            Employer employer = _employerAccountsCommand.CreateTestEmployer(userId, _organisationsCommand.CreateTestOrganisation(0));

            employer.EmailAddress = new EmailAddress {
                Address = email
            };
            _employerAccountsCommand.UpdateEmployer(employer);
            _allocationsCommand.CreateAllocation(new Allocation {
                OwnerId = employer.Id, CreditId = _creditsQuery.GetCredit <ContactCredit>().Id
            });
            return(employer);
        }
Ejemplo n.º 12
0
        private Employer CreateEmployer(int index, EmployerSubRole subRole, IOrganisation organisation, params Industry[] industries)
        {
            var employer = _employerAccountsCommand.CreateTestEmployer(string.Format(UserIdFormat, index), _organisationsCommand.CreateTestOrganisation(0));

            employer.SubRole = subRole;
            if (organisation != null)
            {
                employer.Organisation = organisation;
            }
            if (industries != null)
            {
                employer.Industries = industries.ToList();
            }
            _employerAccountsCommand.UpdateEmployer(employer);

            _allocationsCommand.CreateAllocation(new Allocation {
                OwnerId = employer.Id, CreditId = _creditsQuery.GetCredit <ContactCredit>().Id, ExpiryDate = DateTime.Now.AddDays(100), InitialQuantity = 100
            });
            return(employer);
        }
Ejemplo n.º 13
0
        public ActionResult Settings(SettingsModel settings)
        {
            var employer = CurrentEmployer;

            settings.CanEditOrganisationName = !employer.Organisation.IsVerified;
            settings.Industries  = _industriesQuery.GetIndustries();
            settings.Allocations = GetAllocations(employer);
            var credentials = _loginCredentialsQuery.GetCredentials(employer.Id);

            settings.HasLoginCredentials = credentials != null;

            try
            {
                // Validate before changing.

                settings.Prepare();
                settings.Validate();

                // Update the credentials.

                UpdateCredentials(employer.Id, credentials, settings.LoginId, settings.Password, settings.ConfirmPassword, settings.UseLinkedInProfile);

                // Update.

                employer.FirstName   = settings.FirstName;
                employer.LastName    = settings.LastName;
                employer.PhoneNumber = _phoneNumbersQuery.GetPhoneNumber(settings.PhoneNumber, ActivityContext.Current.Location.Country);
                employer.Industries  = settings.IndustryIds == null
                    ? null
                    : (from i in settings.IndustryIds select _industriesQuery.GetIndustry(i)).ToList();
                employer.SubRole  = settings.Role;
                employer.JobTitle = settings.JobTitle;

                _employerAccountsCommand.UpdateEmployer(employer);

                // Update the organisation.

                if (settings.CanEditOrganisationName)
                {
                    UpdateOrganisation(employer, settings.OrganisationName);
                }

                // Suggested candidates.

                UpdateSuggestedCandidates(employer, settings.ShowSuggestedCandidates, settings.SendSuggestedCandidates, settings.ReceiveSuggestedCandidates);

                // Communications.

                UpdateCommunicationSettings(employer.Id, settings.EmailEmployerUpdate, settings.EmailCampaign);

                // Reset the display name cached in the authentication details, in case the user updated any details that affect it.

                _authenticationManager.UpdateUser(HttpContext, employer, false);

                return(RedirectToReturnUrlWithConfirmation("Your changes have been saved."));
            }
            catch (UserException ex)
            {
                ModelState.AddModelError(ex, new StandardErrorHandler());
            }

            return(View(settings));
        }