コード例 #1
0
        public static bool validateMemberProfileResponse(MemberProfileQAModel memberProfleResponse)
        {
            var validationResults = new List <ValidationResult>();
            //validate memberProfileResponse
            var  validationContext = new ValidationContext(memberProfleResponse, serviceProvider: null, items: null);
            bool isValid           = System.ComponentModel.DataAnnotations.Validator.TryValidateObject(memberProfleResponse, validationContext, validationResults, true);

            return(isValid);
        }
コード例 #2
0
        /// <summary>
        /// To the domain object for member profile questions and answers.
        /// </summary>
        /// <param name="memberProfileQAContracts">member profile question and answer contracts.</param>
        /// <returns>List<MemberProfileQAModel></returns>
        public static List <MemberProfileQAModel> ToDomainObject(this MemberProfileQAContract[] memberProfileQAContracts)
        {
            var toReturn = new List <MemberProfileQAModel>()
            {
            };

            if (memberProfileQAContracts != null)
            {
                foreach (var response in memberProfileQAContracts)
                {
                    var model = new MemberProfileQAModel()
                    {
                    };
                    model.QuestionName       = response.ProfileQuestionName;
                    model.QuestionExternalId = response.ProfileQuestionExternalID;
                    model.AnsName            = response.ProfileAnswerName;
                    model.AnsDescription     = response.ProfileAnswerDescription;
                    model.AnsExternalId      = response.ProfileAnswerExternalID;
                    model.CustomValue        = response.CustomValue;
                    toReturn.Add(model);
                }
            }
            return(toReturn);
        }
コード例 #3
0
        public string BuildOutEndecaBoost(int memberId)
        {
            //first remove any objects that do not have an external question or Answer Id
            //These have no tie in to endeca content to boost a record.

            List <ProfileResponseModel> profileResponses = GetProfileResponses(memberId);

            List <MemberProfileQAModel> workingList = new List <MemberProfileQAModel>();

            foreach (var mpqa in profileResponses)
            {
                //if either is null or empty, skip
                if (mpqa.AnsExternalId == 0 || mpqa.QuestionExternalId == 0)
                {
                    continue;
                }
                else
                {
                    //only need question and answer so just filling those 2 values in.
                    MemberProfileQAModel mpqam = new MemberProfileQAModel();
                    mpqam.AnsExternalId      = mpqa.AnsExternalId;
                    mpqam.QuestionExternalId = mpqa.QuestionExternalId;
                    workingList.Add(mpqam);
                }
            }

            int maxNumberOfQuestionsToBoost = 10;

            String beginningPiece = "Endeca.stratify(collection()/record[";
            String endingPiece    = "],*)";
            String orPiece        = " or ";
            String dimensionName  = "Persona";

            String queryBooster = "{0}=collection(\"dimensions\")/dval[name=\"{0}\"]/dval[name=\"{1}\"]/dval[name=\"{2}\"]//id";

            String queryString = String.Empty;

            int i = 0;
            int profileResponsesCount = workingList.Count;

            foreach (MemberProfileQAModel mpqa in workingList)
            {
                i++;

                //put on the beginning piece of the string on last response
                if (i == 1)
                {
                    queryString = beginningPiece;
                }

                if (i <= profileResponsesCount)
                {
                    queryString += String.Format(queryBooster, dimensionName, mpqa.QuestionExternalId, mpqa.AnsExternalId);
                    //more than one record && it's not the last record or the maxNumberOfQuestionsToBoost
                    if (profileResponsesCount > 1 && (profileResponsesCount > i && maxNumberOfQuestionsToBoost != i))
                    {
                        queryString += orPiece;
                    }
                }

                //put on the ending piece of the string on last response
                if (i == profileResponsesCount || i == maxNumberOfQuestionsToBoost)
                {
                    queryString += endingPiece;
                    break;
                }
            }

            return(queryString);
        }