Beispiel #1
0
        private IEnumerable<ItemTransactionAnswer> PopulateItemTransactionAnswer(OpenIdUser openIdUser, ICollection<ItemQuestionSet> questionSets)
        {
            var answers = new List<ItemTransactionAnswer>();

            // if anything is null, just return no answers
            if (openIdUser == null || questionSets == null) return answers;

            // find the contact information question set
            var questionSet = questionSets.Where(a => a.QuestionSet.Name == StaticValues.QuestionSet_ContactInformation).Select(a => a.QuestionSet).FirstOrDefault();

            // if it exists, fill in the questions
            if (questionSet != null)
            {
                var questionAnswer = new Dictionary<string, string>();
                questionAnswer.Add(StaticValues.Question_FirstName, openIdUser.FirstName);
                questionAnswer.Add(StaticValues.Question_LastName, openIdUser.LastName);
                questionAnswer.Add(StaticValues.Question_StreetAddress, openIdUser.StreetAddress);
                questionAnswer.Add(StaticValues.Question_AddressLine2, openIdUser.Address2);
                questionAnswer.Add(StaticValues.Question_City, openIdUser.City);
                questionAnswer.Add(StaticValues.Question_State, openIdUser.State);
                questionAnswer.Add(StaticValues.Question_Zip, openIdUser.Zip);
                questionAnswer.Add(StaticValues.Question_PhoneNumber, openIdUser.PhoneNumber);
                questionAnswer.Add(StaticValues.Question_Email, openIdUser.Email);
                foreach (var question in questionSet.Questions)
                {
                    //If it doesn't find the question, it will throw an exception. (a good thing.)
                    var ans = questionAnswer[question.Name];
                    // create the answer object
                    var answer = new ItemTransactionAnswer()
                    {
                        Answer = ans,
                        QuestionId = question.Id,
                        QuestionSetId = question.QuestionSet.Id,
                        Transaction = true
                    };

                    answers.Add(answer);
                }

                #region old way answers were assigned
                //foreach(var question in questionSet.Questions)
                //{
                //    var ans = string.Empty;

                //    if (question.Name == StaticValues.Question_FirstName)
                //    {
                //        ans = openIdUser.FirstName;
                //    }
                //    else if (question.Name == StaticValues.Question_LastName)
                //    {
                //        ans = openIdUser.LastName;
                //    }
                //    else if (question.Name == StaticValues.Question_StreetAddress)
                //    {
                //        ans = openIdUser.StreetAddress;
                //    }
                //    else if (question.Name == StaticValues.Question_AddressLine2)
                //    {
                //        ans = openIdUser.Address2;
                //    }
                //    else if (question.Name == StaticValues.Question_City)
                //    {
                //        ans = openIdUser.City;
                //    }
                //    else if (question.Name == StaticValues.Question_State)
                //    {
                //        ans = openIdUser.State;
                //    }
                //    else if (question.Name == StaticValues.Question_Zip)
                //    {
                //        ans = openIdUser.Zip;
                //    }
                //    else if (question.Name == StaticValues.Question_PhoneNumber)
                //    {
                //        ans = openIdUser.PhoneNumber;
                //    }
                //    else if (question.Name == StaticValues.Question_Email)
                //    {
                //        ans = openIdUser.Email;
                //    }

                //    // create the answer object
                //    var answer = new ItemTransactionAnswer()
                //    {
                //        Answer = ans,
                //        QuestionId = question.Id,
                //        QuestionSetId = question.QuestionSet.Id,
                //        Transaction = true
                //    };

                //    answers.Add(answer);
                //}
                #endregion old way answers were assigned
            }

            return answers;
        }
Beispiel #2
0
        private IEnumerable<ItemTransactionAnswer> PopulateItemTransactionAnswer(QuestionAnswerParameter[] transactionAnswers, QuestionAnswerParameter[] quantityAnswers)
        {
            var answers = new List<ItemTransactionAnswer>();

            foreach (var qap in transactionAnswers)
            {
                var question = Repository.OfType<Question>().GetNullableById(qap.QuestionId);
                var answer = qap.Answer;

                if (question != null)
                {
                    if (question.QuestionType.Name == QuestionTypeText.STR_CheckboxList && qap.CblAnswer != null)
                        answer = string.Join(",", qap.CblAnswer);
                }

                var a = new ItemTransactionAnswer()
                            {
                                Answer = answer,
                                QuestionId = qap.QuestionId,
                                QuestionSetId = qap.QuestionSetId,
                                Transaction = true
                            };

                answers.Add(a);
            }

            foreach (var qap in quantityAnswers)
            {
                var question = Repository.OfType<Question>().GetNullableById(qap.QuestionId);
                var answer = qap.Answer;

                if (question != null)
                {
                    if (question.QuestionType.Name == QuestionTypeText.STR_CheckboxList && qap.CblAnswer != null)
                        answer = string.Join(",", qap.CblAnswer);
                }

                var a = new ItemTransactionAnswer()
                            {
                                Answer = answer,
                                QuestionId = qap.QuestionId,
                                QuestionSetId = qap.QuestionSetId,
                                QuantityIndex = qap.QuantityIndex,
                                Transaction = false
                            };

                answers.Add(a);
            }

            return answers;
        }
Beispiel #3
0
        /// <summary>
        /// This one is used for Agribusiness to pass these values.
        /// </summary>
        /// <param name="agribusinessExtraParams"></param>
        /// <param name="questionSets"></param>
        /// <returns></returns>
        private IEnumerable<ItemTransactionAnswer> PopulateItemTransactionAnswer(AgribusinessExtraParams agribusinessExtraParams, ICollection<ItemQuestionSet> questionSets)
        {
            var answers = new List<ItemTransactionAnswer>();

            // if anything is null, just return no answers
            if(agribusinessExtraParams == null || questionSets == null)
                return answers;

            // find the contact information question set
            var questionSet = questionSets.Where(a => a.QuestionSet.Name == StaticValues.QuestionSet_ContactInformation).Select(a => a.QuestionSet).FirstOrDefault();

            // if it exists, fill in the questions
            if(questionSet != null)
            {
                var questionAnswer = new Dictionary<string, string>();
                questionAnswer.Add(StaticValues.Question_FirstName, agribusinessExtraParams.FN);
                questionAnswer.Add(StaticValues.Question_LastName, agribusinessExtraParams.LN);
                questionAnswer.Add(StaticValues.Question_Title, agribusinessExtraParams.Title);
                questionAnswer.Add(StaticValues.Question_StreetAddress, agribusinessExtraParams.Address);
                questionAnswer.Add(StaticValues.Question_AddressLine2, agribusinessExtraParams.Address2);
                questionAnswer.Add(StaticValues.Question_City, agribusinessExtraParams.City);
                questionAnswer.Add(StaticValues.Question_State, agribusinessExtraParams.State != null ? agribusinessExtraParams.State.Trim().ToUpper() : string.Empty);
                questionAnswer.Add(StaticValues.Question_Zip, agribusinessExtraParams.Zip);
                questionAnswer.Add(StaticValues.Question_PhoneNumber, agribusinessExtraParams.Phone != null ? agribusinessExtraParams.Phone.Replace('.', '-') : string.Empty);
                questionAnswer.Add(StaticValues.Question_Email, agribusinessExtraParams.Email);
                foreach(var question in questionSet.Questions)
                {
                    //If it doesn't find the question, it will throw an exception. (a good thing.)
                    var ans = questionAnswer[question.Name];
                    // create the answer object
                    var answer = new ItemTransactionAnswer()
                    {
                        Answer = ans,
                        QuestionId = question.Id,
                        QuestionSetId = question.QuestionSet.Id,
                        Transaction = true
                    };

                    answers.Add(answer);
                }

            }

            return answers;
        }