Пример #1
0
        private FieldDefinition CreateField(FieldDefinition fieldDefinition)
        {
            var currentField = _fieldDefinitionService.Get<ProductArea>(fieldDefinition.Id);
            if (currentField != null)
            {
                // Update options of the field even if the field already exists
                if (fieldDefinition.Option != null)
                {
                    currentField = currentField.MakeWritableClone();
                    currentField.Option = fieldDefinition.Option;
                    _fieldDefinitionService.Update(currentField);
                }

                return currentField;
            }

            _fieldDefinitionService.Create(fieldDefinition);
            return _fieldDefinitionService.Get<ProductArea>(fieldDefinition.Id);
        }
Пример #2
0
        private void Import(TextOptionImportPageViewModel textOptionImportPageViewModel, DataSet content)
        {
            var textOptions = GetTextOptionsFromExcelContent(content);

            var timer = new Stopwatch();

            timer.Start();

            var textOptionField = GetOrCreateTextOptionField(textOptionImportPageViewModel);

            var option = CreateOptionOnNewTextOption(textOptionField);

            foreach (var textOption in textOptions)
            {
                AddOptionsToTextOptionField(textOptionImportPageViewModel, textOptionField, option, textOption);
            }

            _fieldDefinitionService.Update(textOptionField);

            timer.Stop();

            this.Log().Info($"Time taken in seconds: {timer.Elapsed.TotalSeconds}");
        }