コード例 #1
0
        public static InterchangeTemplate MapToInterchangeTemplate(InterchangeTemplateCreateCommand command)
        {
            ValidationUtil.NotNull <InterchangeTemplateCreateCommand>(command);
            var interchangeTemplate = new InterchangeTemplate();

            interchangeTemplate.SequenceNumber       = command.SequenceNumber;
            interchangeTemplate.IsMandatory          = command.IsMandatory;
            interchangeTemplate.IsDescriptionVisible = command.IsDescriptionVisible;
            var numberOfQuestionsPresent = GetNumberOfQuestionsPresent(command);

            if (numberOfQuestionsPresent != 1)
            {
                throw new InvalidArgumentException(nameof(numberOfQuestionsPresent), numberOfQuestionsPresent.ToString(), "Exactly one");
            }
            if (IsTextQuestionPresent(command.TextQuestion))
            {
                interchangeTemplate.Question = command.TextQuestion;
            }
            if (IsRangeQuestionPresent(command.RangeQuestion))
            {
                interchangeTemplate.Question = command.RangeQuestion;
            }
            if (IsMultipleChoiceQuestionPresent(command.MultipleChoiceQuestion))
            {
                interchangeTemplate.Question = command.MultipleChoiceQuestion;
            }

            return(interchangeTemplate);
        }