コード例 #1
0
        public void TestJoin()
        {
            // Not logged in.

            AssertJsonError(Deserialize <JsonResponseModel>(Get(HttpStatusCode.Forbidden, _profileUrl)), null, "100", "The user is not logged in.");

            // Join.

            var model = new EmployerJoinModel
            {
                LoginId          = LoginId,
                Password         = Password,
                FirstName        = FirstName,
                LastName         = LastName,
                EmailAddress     = EmailAddress,
                Location         = Location,
                OrganisationName = OrganisationName,
                PhoneNumber      = PhoneNumber,
                SubRole          = EmployerSubRole.Recruiter,
            };

            AssertJsonSuccess(Join(model));

            // Check now logged in.

            AssertJsonSuccess(Deserialize <JsonResponseModel>(Get(_profileUrl)));

            // Check.

            var id = _loginCredentialsQuery.GetUserId(LoginId);

            AssertEmployer(model, _employersQuery.GetEmployer(id.Value));
        }
コード例 #2
0
 private static void AssertEmployer(EmployerJoinModel model, Employer employer)
 {
     Assert.AreEqual(model.FirstName, employer.FirstName);
     Assert.AreEqual(model.LastName, employer.LastName);
     Assert.AreEqual(model.EmailAddress, employer.EmailAddress.Address);
     Assert.AreEqual(model.Location, employer.Organisation.Address.Location.ToString());
     Assert.AreEqual(model.OrganisationName, employer.Organisation.Name);
     Assert.AreEqual(model.PhoneNumber, employer.PhoneNumber.Number);
     Assert.AreEqual(model.SubRole, employer.SubRole);
 }
コード例 #3
0
        public ActionResult Join(EmployerJoinModel joinModel)
        {
            try
            {
                joinModel.Validate();

                // Try to join.

                var account = new EmployerAccount
                {
                    FirstName        = joinModel.FirstName,
                    LastName         = joinModel.LastName,
                    EmailAddress     = joinModel.EmailAddress,
                    Location         = joinModel.Location,
                    OrganisationName = joinModel.OrganisationName,
                    PhoneNumber      = joinModel.PhoneNumber,
                    SubRole          = joinModel.SubRole,
                };

                var credentials = new AccountLoginCredentials
                {
                    LoginId         = joinModel.LoginId,
                    Password        = joinModel.Password,
                    ConfirmPassword = joinModel.Password,
                };

                _accountsManager.Join(HttpContext, account, credentials);
                return(Json(new JsonResponseModel()));
            }
            catch (DuplicateUserException ex)
            {
                ModelState.AddModelError("LoginId", ex.Message);
            }
            catch (UserException ex)
            {
                ModelState.AddModelError(ex, new StandardErrorHandler());
            }

            return(Json(new JsonResponseModel()));
        }
コード例 #4
0
 private JsonResponseModel Join(EmployerJoinModel model)
 {
     return(Deserialize <JsonResponseModel>(Post(_joinUrl, JsonContentType, Serialize(model, new EmployerJoinModelJavaScriptConverter()))));
 }