예제 #1
0
        protected string GetEthnicStatusText()
        {
            string statusText = NetworkerFacade.GetEthnicStatusText(_member, false);

            if (!string.IsNullOrEmpty(statusText))
            {
                statusText = "Indigenous status indicated: " + statusText;
            }

            return(ResumeViewHelper.GetOptionalListItem(statusText));
        }
예제 #2
0
 protected string GetEthnicStatusText()
 {
     return(NetworkerFacade.GetEthnicStatusText(_member, true));
 }
예제 #3
0
        public AjaxResult SaveProfileDetails(string firstName, string lastName,
                                             string gender, int day, int month, string year, string countryStr, string location, int ethnicStatus,
                                             string ageControlName, string ethnicStatusControlName)
        {
            try
            {
                EnsureMemberLoggedIn();

                var errors = new List <string>();

                if (string.IsNullOrEmpty(firstName))
                {
                    errors.Add(ValidationErrorMessages.REQUIRED_FIELD_FIRST_NAME);
                }

                if (string.IsNullOrEmpty(lastName))
                {
                    errors.Add(ValidationErrorMessages.REQUIRED_FIELD_LAST_NAME);
                }

                PartialDate?dateOfBirth = null;
                if (day != 0 && month != 0 && !string.IsNullOrEmpty(year))
                {
                    try
                    {
                        dateOfBirth = new PartialDate(ParseUtil.ParseUserInputInt32(year, "year of birth"), month, day);
                    }
                    catch (ArgumentException)
                    {
                        errors.Add(ValidationErrorMessages.INVALID_DATE_OF_BIRTH);
                    }
                    catch (UserException ex)
                    {
                        errors.Add(ex.Message);
                    }
                }
                else if (day != 0 || month != 0 || !string.IsNullOrEmpty(year))
                {
                    errors.Add(ValidationErrorMessages.INCOMPLETE_DATE_OF_BIRTH);
                }

                Country country = null;
                if (string.IsNullOrEmpty(countryStr))
                {
                    errors.Add(ValidationErrorMessages.REQUIRED_FIELD_COUNTRY);
                }
                else
                {
                    country = _locationQuery.GetCountry(countryStr);
                    if (country == null)
                    {
                        errors.Add(ValidationErrorMessages.INVALID_COUNTRY);
                    }
                }

                if (string.IsNullOrEmpty(location))
                {
                    errors.Add(ValidationErrorMessages.REQUIRED_FIELD_SUBURB);
                }

                if (errors.Count > 0)
                {
                    return(new AjaxResult(AjaxResultCode.FAILURE, errors.ToArray()));
                }

                var member = LoggedInMember;
                member.FirstName        = firstName;
                member.LastName         = lastName;
                member.Address.Location = _locationQuery.ResolveLocation(country, location);
                member.DateOfBirth      = dateOfBirth;
                member.Gender           = GetGender(member, gender);
                member.EthnicStatus     = (EthnicStatus)ethnicStatus;
                _memberAccountsCommand.UpdateMember(member);

                _authenticationManager.UpdateUser(new HttpContextWrapper(HttpContext.Current), member, false);

                var ageValue          = member.DateOfBirth.GetAgeDisplayText();
                var ethnicStatusValue = NetworkerFacade.GetEthnicStatusText(member, true);

                var userData = new ElementValuesUserData(
                    new[] { ageControlName, ethnicStatusControlName },
                    new[] { ageValue, ethnicStatusValue });

                return(new AjaxResult(AjaxResultCode.SUCCESS, null, userData));
            }
            catch (Exception ex)
            {
                return(HandleException(ex));
            }
        }