internal static Distractor ConvertDto(DistractorDTO q, Distractor instance, bool updateQuestionDate, FileModel fileModel, QuestionModel questionModel, UserModel userModel, SubModuleItemModel subModuleItemModel) { instance = instance ?? new Distractor(); instance.IsActive = q.isActive; instance.DistractorName = q.distractor; instance.DistractorOrder = q.distractorOrder; instance.Score = q.score; instance.IsCorrect = q.isCorrect; if (instance.IsTransient()) { instance.DateCreated = DateTime.Now; } instance.DateModified = DateTime.Now; instance.Image = q.imageId.HasValue ? fileModel.GetOneById(q.imageId.Value).Value : null; instance.LeftImage = q.leftImageId.HasValue ? fileModel.GetOneById(q.leftImageId.Value).Value : null; instance.RightImage = q.rightImageId.HasValue ? fileModel.GetOneById(q.rightImageId.Value).Value : null; instance.Question = q.questionId.HasValue ? questionModel.GetOneById(q.questionId.Value).Value : null; instance.ModifiedBy = q.modifiedBy.HasValue ? userModel.GetOneById(q.modifiedBy.Value).Value : null; instance.CreatedBy = q.createdBy.HasValue ? userModel.GetOneById(q.createdBy.Value).Value : null; instance.DistractorType = q.distractorType; if (instance.Question != null && updateQuestionDate) { var subModuleItem = instance.Question.SubModuleItem; subModuleItem.DateModified = DateTime.Now; subModuleItemModel.RegisterSave(subModuleItem); } return(instance); }
/// <summary> /// The convert DTO. /// </summary> /// <param name="itemDTO"> /// The user. /// </param> /// <param name="instance"> /// The instance. /// </param> /// <returns> /// The <see cref="Test"/>. /// </returns> private Test ConvertDto(TestDTO itemDTO, Test instance) { instance = instance ?? new Test(); instance.TestName = itemDTO.testName; instance.Description = itemDTO.description; instance.InstructionTitle = itemDTO.instructionTitle; instance.InstructionDescription = itemDTO.instructionDescription; instance.PassingScore = itemDTO.passingScore; instance.ScoreFormat = itemDTO.scoreFormat; instance.TimeLimit = itemDTO.timeLimit; instance.SubModuleItem = itemDTO.subModuleItemId.HasValue ? SubModuleItemModel.GetOneById(itemDTO.subModuleItemId.Value).Value : null; instance.ScoreType = itemDTO.scoreTypeId.HasValue ? ScoreTypeModel.GetOneById(itemDTO.scoreTypeId.Value).Value ?? ScoreTypeModel.GetOneById(1).Value : this.ScoreTypeModel.GetOneById(1).Value; if (instance.SubModuleItem != null) { instance.SubModuleItem.DateModified = DateTime.Now; SubModuleItemModel.RegisterSave(instance.SubModuleItem); } return instance; }