private MatrixRatingAnswer MatchMatrixRatingAnswer(Question question, IEnumerable <ResponseAnswer> responseAnswers)
        {
            var reply = new MatrixRatingAnswer
            {
                Rows = new List <MatrixRatingAnswerRow>()
            };

            foreach (var responseAnswer in responseAnswers)
            {
                if (responseAnswer.Row == 0)
                {
                    reply.OtherText = responseAnswer.Text;
                }
                else
                {
                    var row = new MatrixRatingAnswerRow
                    {
                        RowName = question.AnswersLookup[responseAnswer.Row].Text
                    };

                    if (responseAnswer.Col != 0)
                    {
                        row.Choice = question.AnswersLookup[responseAnswer.Col].Text;
                    }

                    if (!String.IsNullOrEmpty(responseAnswer.Text))
                    {
                        row.OtherText = responseAnswer.Text;
                    }
                    reply.Rows.Add(row);
                }
            }

            return(reply);
        }
        private MatrixRatingAnswer MatchMatrixRatingAnswer(Question question, IEnumerable <ResponseAnswer> responseAnswers)
        {
            var reply = new MatrixRatingAnswer
            {
                Rows = new List <MatrixRatingAnswerRow>()
            };

            var rowDictionary = new Dictionary <long, MatrixRatingAnswerRow>();

            foreach (var responseAnswer in responseAnswers)
            {
                if (!responseAnswer.RowId.HasValue)
                {
                    reply.OtherText = responseAnswer.Text;
                }
                else
                {
                    MatrixRatingAnswerRow row;
                    if (!rowDictionary.ContainsKey(responseAnswer.RowId.Value))
                    {
                        var rowName = question.Answers.ItemLookup.ContainsKey(responseAnswer.RowId.Value) ? question.Answers.ItemLookup[responseAnswer.RowId.Value] : null;
                        row = new MatrixRatingAnswerRow
                        {
                            RowName = rowName
                        };
                        rowDictionary.Add(responseAnswer.RowId.Value, row);
                    }
                    else
                    {
                        row = rowDictionary[responseAnswer.RowId.Value];
                    }

                    if (responseAnswer.ChoiceId.HasValue)
                    {
                        if (question.Answers.ItemLookup.ContainsKey(responseAnswer.ChoiceId.Value))
                        {
                            row.Choice = question.Answers.ItemLookup[responseAnswer.ChoiceId.Value];
                        }
                    }

                    if (responseAnswer.OtherId.HasValue)
                    {
                        row.OtherText = responseAnswer.Text;
                    }
                }
            }
            reply.Rows = rowDictionary.Values.ToList();

            return(reply);
        }
        private MatrixRatingAnswer MatchMatrixRatingAnswer(Question question, IEnumerable<ResponseAnswer> responseAnswers)
        {
            var reply = new MatrixRatingAnswer
            {
                Rows = new List<MatrixRatingAnswerRow>()
            };

            foreach (var responseAnswer in responseAnswers)
            {
                if (responseAnswer.Row == 0)
                {
                    reply.OtherText = responseAnswer.Text;
                }
                else
                {
                    var row = new MatrixRatingAnswerRow
                    {
                        RowName = question.AnswersLookup[responseAnswer.Row].Text
                    };

                    if (responseAnswer.Col != 0)
                    {
                        row.Choice = question.AnswersLookup[responseAnswer.Col].Text;
                    }
                    
                    if (!String.IsNullOrEmpty(responseAnswer.Text))
                    {
                        row.OtherText = responseAnswer.Text;
                    }
                    reply.Rows.Add(row);
                }
            }

            return reply;
        }