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); }
// Todo Interviewers ?? public static InterviewRound MapToInterviewRound(InterviewRoundCreateCommand command) { var interviewRound = new InterviewRound { SequenceNumber = command.SequenceNumber }; if (command.Questionnaire?.Any() == true) { interviewRound.Questionnaire = command.Questionnaire.Select(x => InterchangeTemplateCreateCommand.MapToInterchangeTemplate(x)); } return(interviewRound); }
private static int GetNumberOfQuestionsPresent(InterchangeTemplateCreateCommand command) { int count = 0; if (IsTextQuestionPresent(command.TextQuestion)) { count++; } if (IsMultipleChoiceQuestionPresent(command.MultipleChoiceQuestion)) { count++; } if (IsRangeQuestionPresent(command.RangeQuestion)) { count++; } return(count); }