public async Task <CustomEntityDataModelSchema> ExecuteAsync(GetCustomEntityDataModelSchemaDetailsByDefinitionCodeQuery query, IExecutionContext executionContext) { var definitionQuery = new GetCustomEntityDefinitionSummaryByCodeQuery(query.CustomEntityDefinitionCode); var definition = await _queryExecutor.ExecuteAsync(definitionQuery); if (definition == null) { return(null); } var result = new CustomEntityDataModelSchema(); _dynamicDataModelTypeMapper.Map(result, definition.DataModelType); return(result); }
/// <summary> /// Maps an EF PageBlockType record from the db into an PageBlockTypeDetails /// object. If the db record is null then null is returned. /// </summary> /// <param name="blockTypeSummary">PageBlockType record from the database.</param> public PageBlockTypeDetails Map(PageBlockTypeSummary blockTypeSummary) { var result = new PageBlockTypeDetails() { Description = blockTypeSummary.Description, FileName = blockTypeSummary.FileName, Name = blockTypeSummary.Name, PageBlockTypeId = blockTypeSummary.PageBlockTypeId, Templates = blockTypeSummary.Templates }; var dataModelType = GetPageBlockDataModelType(result); _dynamicDataModelTypeMapper.Map(result, dataModelType); return(result); }
public async Task <IDictionary <string, CustomEntityDataModelSchema> > ExecuteAsync(GetCustomEntityDataModelSchemaDetailsByDefinitionCodeRangeQuery query, IExecutionContext executionContext) { var definitionQuery = new GetAllCustomEntityDefinitionSummariesQuery(); var definitions = await _queryExecutor.ExecuteAsync(definitionQuery, executionContext); var results = new Dictionary <string, CustomEntityDataModelSchema>(); foreach (var definition in definitions .Where(d => query.CustomEntityDefinitionCodes.Contains(d.CustomEntityDefinitionCode))) { var result = new CustomEntityDataModelSchema(); result.CustomEntityDefinitionCode = definition.CustomEntityDefinitionCode; _dynamicDataModelTypeMapper.Map(result, definition.DataModelType); results.Add(definition.CustomEntityDefinitionCode, result); } return(results); }
public Task <NestedDataModelSchema> ExecuteAsync(GetNestedDataModelSchemaByNameQuery query, IExecutionContext executionContext) { NestedDataModelSchema result = null; if (string.IsNullOrWhiteSpace(query.Name)) { return(Task.FromResult(result)); } var dataModelType = _nestedDataModelRepository.GetByName(query.Name); if (dataModelType == null) { return(Task.FromResult(result)); } result = new NestedDataModelSchema(); _dynamicDataModelTypeMapper.Map(result, dataModelType); return(Task.FromResult(result)); }
public NestedDataModelSchema Map(Type modelType) { if (modelType == null) { throw new ArgumentNullException(nameof(modelType)); } var schema = new NestedDataModelSchema(); var dataModelMetaData = _modelMetadataProvider.GetMetadataForType(modelType); schema.TypeName = modelType.Name; schema.Description = dataModelMetaData.Description; schema.DisplayName = dataModelMetaData.DisplayName; if (string.IsNullOrEmpty(schema.DisplayName)) { var modelName = StringHelper.RemoveSuffix(modelType.Name, "DataModel"); schema.DisplayName = TextFormatter.PascalCaseToSentence(modelName); } _dynamicDataModelSchemaMapper.Map(schema, modelType); return(schema); }