Пример #1
0
        private static void FillAlternatives(List <string> alternatives, ref List <AnswerModel> result)
        {
            var alternativeResult = new List <AnswerModel>();

            foreach (var alternative in alternatives)
            {
                FillSingleAnswerOrAllWords(alternative, ref alternativeResult);
            }

            var model = new AnswerModel {
                Type = AnswerType.Alternatives, Alternatives = alternativeResult
            };

            result.Add(model);
        }
Пример #2
0
        private static void FillSingleAnswerOrAllWords(string answer, ref List <AnswerModel> result)
        {
            var allWordsCollection = answer.SplitStringByDelimiter(CommonConstants.Delimiter).Select(w => w.ToLower()).ToList();

            if (allWordsCollection.Count == 1)
            {
                result.Add(
                    new AnswerModel {
                    SingleAnswer = allWordsCollection.First(), Type = AnswerType.SingleAnswer
                });
            }
            else
            {
                var model = new AnswerModel {
                    Type = AnswerType.AllWordsInside, AllWordsInside = allWordsCollection
                };
                result.Add(model);
            }
        }