Exemple #1
0
        private JsonConverter GetDataTypeConverter(string customEntityDefinitionCode)
        {
            // If there's no code then the model probably wasn't supplied and should be
            // considered null which will cause a validation error
            if (string.IsNullOrWhiteSpace(customEntityDefinitionCode))
            {
                return(null);
            }

            // If there is a code but it's not registered in the system, then thats exeptional and we should throw
            var definition = _customEntityDefinitionRepository.GetRequiredByCode(customEntityDefinitionCode);

            var dataModelType = definition.GetDataModelType();
            var converterType = _entityDataModelJsonConverterFactory.Create(dataModelType);

            return(converterType);
        }
Exemple #2
0
        private async Task <JsonConverter> GetBlockDataTypeConverterAsync(int?pageBlockTypeId)
        {
            // If there's no id then the model probably wasn't supplied and should be
            // considered null which will cause a validation error
            if (!pageBlockTypeId.HasValue || pageBlockTypeId < 1)
            {
                return(null);
            }

            var dataBlockType = await _pageBlockTypeDataModelTypeFactory.CreateByPageBlockTypeIdAsync(pageBlockTypeId.Value);

            EntityNotFoundException.ThrowIfNull(dataBlockType, pageBlockTypeId);

            var converter = _entityDataModelJsonConverterFactory.Create(dataBlockType);

            return(converter);
        }