Esempio n. 1
0
        public ActionResult ContactDetails(ContactDetailsMemberModel memberModel)
        {
            try
            {
                var member    = CurrentMember;
                var candidate = _candidatesQuery.GetCandidate(member.Id);
                var resume    = candidate.ResumeId == null ? null : _resumesQuery.GetResume(candidate.ResumeId.Value);

                // Check.

                Validate(memberModel);

                // Update.

                UpdateMember(member, m => UpdateMember(m, memberModel));
                UpdateCandidate(candidate, c => UpdateCandidate(c, memberModel));
                resume = UpdateResume(candidate, resume, r => UpdateResume(r, memberModel));

                SendVerifications(member);

                return(Json(new JsonProfileModel {
                    Profile = CreateProfileModel(member, candidate, resume)
                }));
            }
            catch (UserException ex)
            {
                ModelState.AddModelError(ex, new StandardErrorHandler());
            }

            return(Json(new JsonResponseModel()));
        }
Esempio n. 2
0
        private void UpdateMember(Member member, ContactDetailsMemberModel memberModel)
        {
            // Names.

            member.FirstName = memberModel.FirstName;
            member.LastName  = memberModel.LastName;

            // Location.

            var country = _locationQuery.GetCountry(memberModel.CountryId ?? ActivityContext.Location.Country.Id);

            member.Address.Location = _locationQuery.ResolveLocation(country, memberModel.Location);

            // Email addresses.

            member.EmailAddresses = new List <EmailAddress> {
                new EmailAddress {
                    Address = memberModel.EmailAddress
                }
            };
            if (!string.IsNullOrEmpty(memberModel.SecondaryEmailAddress))
            {
                member.EmailAddresses.Add(new EmailAddress {
                    Address = memberModel.SecondaryEmailAddress
                });
            }

            // Phone numbers.

            member.PhoneNumbers = new List <PhoneNumber> {
                new PhoneNumber {
                    Number = memberModel.PhoneNumber, Type = memberModel.PhoneNumberType
                }
            };
            if (!string.IsNullOrEmpty(memberModel.SecondaryPhoneNumber))
            {
                member.PhoneNumbers.Add(new PhoneNumber {
                    Number = memberModel.SecondaryPhoneNumber, Type = memberModel.SecondaryPhoneNumberType
                });
            }

            // Others.

            member.EthnicStatus = memberModel.EthnicStatus;
            member.Gender       = memberModel.Gender;
            member.DateOfBirth  = memberModel.DateOfBirth;
        }
Esempio n. 3
0
        private void Validate(ContactDetailsMemberModel memberModel)
        {
            memberModel.Prepare();

            // Gather all errors.

            var errors = memberModel.GetValidationErrors().ToList();

            // Validate the location separately.

            if (!string.IsNullOrEmpty(memberModel.Location))
            {
                var country = memberModel.CountryId == null
                    ? ActivityContext.Location.Country
                    : _locationQuery.GetCountry(memberModel.CountryId.Value);
                var        location  = _locationQuery.ResolveLocation(country, memberModel.Location);
                IValidator validator = new PostalSuburbValidator();
                if (!validator.IsValid(location))
                {
                    errors = errors.Concat(validator.GetValidationErrors("Location")).ToList();
                }
                else
                {
                    memberModel.Location = location.ToString();
                }
            }

            // Gender and date of birth are required.

            if (memberModel.Gender == Gender.Unspecified)
            {
                errors.Add(new RequiredValidationError("Gender"));
            }
            if (memberModel.DateOfBirth == null)
            {
                errors.Add(new RequiredValidationError("DateOfBirth"));
            }

            if (errors.Any())
            {
                throw new ValidationErrorsException(errors);
            }
        }
Esempio n. 4
0
 private static void UpdateResume(Resume resume, ContactDetailsMemberModel memberModel)
 {
     resume.Citizenship = memberModel.Citizenship;
 }
Esempio n. 5
0
 private static void UpdateCandidate(Candidate candidate, ContactDetailsMemberModel memberModel)
 {
     candidate.VisaStatus = memberModel.VisaStatus;
 }