Exemple #1
0
        private static void SetReservationStatus(IContentBase apartment, string valueName)
        {
            var dts          = new DataTypeService();
            var statusEditor = dts.GetAllDataTypeDefinitions().First(x => x.Name == "Status Rezerwacji");
            var preValueId   = dts.GetPreValuesCollectionByDataTypeId(statusEditor.Id).PreValuesAsDictionary.Where(d => d.Value.Value == valueName).Select(f => f.Value.Id).First();

            apartment.SetValue("status", preValueId);
        }
        public override void Map(Property property, ContentPropertyDto dest, MapperContext context)
        {
            base.Map(property, dest, context);

            dest.IsRequired       = property.PropertyType.Mandatory;
            dest.ValidationRegExp = property.PropertyType.ValidationRegExp;
            dest.Description      = property.PropertyType.Description;
            dest.Label            = property.PropertyType.Name;
            dest.DataType         = DataTypeService.GetDataType(property.PropertyType.DataTypeId);
        }
        public override ContentPropertyDto Convert(Property property, ContentPropertyDto dest, ResolutionContext context)
        {
            var propertyDto = base.Convert(property, dest, context);

            propertyDto.IsRequired       = property.PropertyType.Mandatory;
            propertyDto.ValidationRegExp = property.PropertyType.ValidationRegExp;
            propertyDto.Description      = property.PropertyType.Description;
            propertyDto.Label            = property.PropertyType.Name;
            propertyDto.DataType         = DataTypeService.GetDataType(property.PropertyType.DataTypeId);

            return(propertyDto);
        }
        public override void Map(IProperty property, ContentPropertyDto dest, MapperContext context)
        {
            base.Map(property, dest, context);

            dest.IsRequired              = property.PropertyType?.Mandatory;
            dest.IsRequiredMessage       = property.PropertyType?.MandatoryMessage;
            dest.ValidationRegExp        = property.PropertyType?.ValidationRegExp;
            dest.ValidationRegExpMessage = property.PropertyType?.ValidationRegExpMessage;
            dest.Description             = property.PropertyType?.Description;
            dest.Label      = property.PropertyType?.Name;
            dest.DataType   = property.PropertyType is null ? null : DataTypeService.GetDataType(property.PropertyType.DataTypeId);
            dest.LabelOnTop = property.PropertyType?.LabelOnTop;
        }
        public override void Up()
        {
            //Create a new Data Type called "Videolizer"
            DataTypeService dataTypeService = (DataTypeService)ApplicationContext.Current.Services.DataTypeService;

            if (dataTypeService.GetDataTypeDefinitionByName("Videolizer") == null)   //check to see if it already exists
            //Create a new one
            {
                DataTypeDefinition VideolizerDataTypeDef = new DataTypeDefinition("DigitalMomentum.Videolizer");
                VideolizerDataTypeDef.Name = "Videolizer";

                dataTypeService.Save(VideolizerDataTypeDef);
            }
        }
    public override void Map(IProperty originalProp, ContentPropertyDisplay dest, MapperContext context)
    {
        base.Map(originalProp, dest, context);

        var config = originalProp.PropertyType is null
            ? null
            : DataTypeService.GetDataType(originalProp.PropertyType.DataTypeId)?.Configuration;

        // TODO: IDataValueEditor configuration - general issue
        // GetValueEditor() returns a non-configured IDataValueEditor
        // - for richtext and nested, configuration determines HideLabel, so we need to configure the value editor
        // - could configuration also determines ValueType, everywhere?
        // - does it make any sense to use a IDataValueEditor without configuring it?

        // configure the editor for display with configuration
        IDataValueEditor?valEditor = dest.PropertyEditor?.GetValueEditor(config);

        // set the display properties after mapping
        dest.Alias       = originalProp.Alias;
        dest.Description = originalProp.PropertyType?.Description;
        dest.Label       = originalProp.PropertyType?.Name;
        dest.HideLabel   = valEditor?.HideLabel ?? false;
        dest.LabelOnTop  = originalProp.PropertyType?.LabelOnTop;

        // add the validation information
        dest.Validation.Mandatory        = originalProp.PropertyType?.Mandatory ?? false;
        dest.Validation.MandatoryMessage = originalProp.PropertyType?.MandatoryMessage;
        dest.Validation.Pattern          = originalProp.PropertyType?.ValidationRegExp;
        dest.Validation.PatternMessage   = originalProp.PropertyType?.ValidationRegExpMessage;

        if (dest.PropertyEditor == null)
        {
            // display.Config = PreValueCollection.AsDictionary(preVals);
            // if there is no property editor it means that it is a legacy data type
            // we cannot support editing with that so we'll just render the readonly value view.
            dest.View = "views/propertyeditors/readonlyvalue/readonlyvalue.html";
        }
        else
        {
            // let the property editor format the pre-values
            dest.Config = dest.PropertyEditor.GetConfigurationEditor().ToValueEditor(config);
            dest.View   = valEditor?.View;
        }

        // Translate
        dest.Label       = _textService.UmbracoDictionaryTranslate(_cultureDictionary, dest.Label);
        dest.Description = _textService.UmbracoDictionaryTranslate(_cultureDictionary, dest.Description);
    }
Exemple #7
0
        public override ContentPropertyDisplay Convert(Property originalProp, ContentPropertyDisplay dest, ResolutionContext context)
        {
            var display = base.Convert(originalProp, dest, context);

            var config = DataTypeService.GetDataType(originalProp.PropertyType.DataTypeId).Configuration;

            // fixme - IDataValueEditor configuration - general issue
            // GetValueEditor() returns a non-configured IDataValueEditor
            // - for richtext and nested, configuration determines HideLabel, so we need to configure the value editor
            // - could configuration also determines ValueType, everywhere?
            // - does it make any sense to use a IDataValueEditor without configuring it?

            // configure the editor for display with configuration
            var valEditor = display.PropertyEditor.GetValueEditor(config);

            //set the display properties after mapping
            display.Alias       = originalProp.Alias;
            display.Description = originalProp.PropertyType.Description;
            display.Label       = originalProp.PropertyType.Name;
            display.HideLabel   = valEditor.HideLabel;

            //add the validation information
            display.Validation.Mandatory = originalProp.PropertyType.Mandatory;
            display.Validation.Pattern   = originalProp.PropertyType.ValidationRegExp;

            if (display.PropertyEditor == null)
            {
                //display.Config = PreValueCollection.AsDictionary(preVals);
                //if there is no property editor it means that it is a legacy data type
                // we cannot support editing with that so we'll just render the readonly value view.
                display.View = "views/propertyeditors/readonlyvalue/readonlyvalue.html";
            }
            else
            {
                //let the property editor format the pre-values
                display.Config = display.PropertyEditor.GetConfigurationEditor().ToValueEditor(config);
                display.View   = valEditor.View;
            }

            //Translate
            display.Label       = _textService.UmbracoDictionaryTranslate(display.Label);
            display.Description = _textService.UmbracoDictionaryTranslate(display.Description);

            return(display);
        }
Exemple #8
0
        public void Run()
        {
            Initialise("TypeSet3");

            var dataTypes         = DataTypeService.GetAllDataTypeDefinitions();
            var expectedDataTypes = GetDataTypes();

            AssertDataTypes(dataTypes, expectedDataTypes);

            var docTypes         = ContentTypeService.GetAllContentTypes();
            var expectedDocTypes = GetDocTypes();

            AssertContentTypes(docTypes, expectedDocTypes);

            var mediaTypes         = ContentTypeService.GetAllMediaTypes();
            var expectedMediaTypes = GetMediaTypes();

            AssertContentTypes(mediaTypes, expectedMediaTypes);
        }
Exemple #9
0
        public ActionResult submit(BookingInfo lunch)
        {
            //Check to see if the submission is valid
            if (!ModelState.IsValid)
            {
                return(CurrentUmbracoPage());
            }

            //get the datatype for the Lunch Choices so we can work with it
            IDataTypeDefinition datatype = Services.DataTypeService.GetDataTypeDefinitionByName("Lunch Choices");
            DataTypeService     dts      = (DataTypeService)Services.DataTypeService;

            //Get the parent ID of content you want to attach the submission to
            var categoryContentType = Services.ContentTypeService.GetContentType("Lunchformpage");
            var parent = Services.ContentService.GetContentOfContentType(categoryContentType.Id).FirstOrDefault(x => x.Name == "Lunch Chooser");

            //Create a new content item under a given parent
            var contentService = Services.ContentService;
            var LunchContent   = contentService.CreateContent(
                lunch.FirstName + " " + lunch.LastName + DateTime.Now, //Name of the new Lunch Submission content
                parent.Id,                                             //Content Parent ID, where these submissions will live under
                "Lunchchoicedata",                                     // the alias of the Document Type we are adding
                0);                                                    //the user adding the record, 0 is the admin

            //Get the preValue of selected lunch choice
            //The dropdown on our form only contained the text and not the true value (prevalue),
            //we need to find the prevalue id and enter the prevalue id into Umbraco
            var statusEditor = dts.GetAllDataTypeDefinitions().First(x => x.Name == "Lunch Choices");
            int preValueId   = dts.GetPreValuesCollectionByDataTypeId(statusEditor.Id).PreValuesAsDictionary.Where(d => d.Value.Value == lunch.LunchChoice).Select(f => f.Value.Id).First();

            //Set the values of each property so that we can add the new item to Umbraco
            LunchContent.SetValue("firstName", lunch.FirstName);
            LunchContent.SetValue("lastName", lunch.LastName);
            LunchContent.SetValue("lunchChoice", preValueId);

            // publish and save the new content
            contentService.SaveAndPublishWithStatus(LunchContent);

            //Return to the same page
            return(CurrentUmbracoPage());
        }
Exemple #10
0
        public void CreateStub()
        {
            string fieldValue       = "test field value";
            string name             = "Target";
            string contentTypeAlias = "TestType";
            string contentTypeName  = "Test Type";

            var unitOfWork  = Global.CreateUnitOfWork();
            var repoFactory = new RepositoryFactory();

            _contentService = new ContentService(unitOfWork, repoFactory);
            var contentTypeService = new ContentTypeService(unitOfWork, repoFactory,
                                                            new ContentService(unitOfWork),
                                                            new MediaService(unitOfWork, repoFactory));
            var dataTypeService = new DataTypeService(unitOfWork, repoFactory);

            var contentType = new ContentType(-1);

            contentType.Name      = contentTypeName;
            contentType.Alias     = contentTypeAlias;
            contentType.Thumbnail = string.Empty;
            contentTypeService.Save(contentType);
            Assert.Greater(contentType.Id, 0);

            var definitions = dataTypeService.GetDataTypeDefinitionByControlId(new Guid("ec15c1e5-9d90-422a-aa52-4f7622c63bea"));

            dataTypeService.Save(definitions.FirstOrDefault());
            var propertyType = new PropertyType(definitions.FirstOrDefault());

            propertyType.Alias = "Property";
            contentType.AddPropertyType(propertyType);
            contentTypeService.Save(contentType);
            Assert.Greater(contentType.Id, 0);

            var content = new Content(name, -1, contentType);

            content.Key = new Guid("{D2517065-2818-4AF7-B851-493E46EA79D5}");
            content.SetPropertyValue("Property", fieldValue);
            _contentService.Save(content);
        }
        public void CreateStub()
        {
            bool   fieldValue       = false;
            string name             = "Target";
            string contentTypeAlias = "TestType";
            string contentTypeName  = "Test Type";

            var unitOfWork  = Global.CreateUnitOfWork();
            var repoFactory = new RepositoryFactory();

            _contentService = new ContentService(unitOfWork, repoFactory);
            var contentTypeService = new ContentTypeService(unitOfWork, repoFactory,
                                                            new ContentService(unitOfWork),
                                                            new MediaService(unitOfWork, repoFactory));
            var dataTypeService = new DataTypeService(unitOfWork, repoFactory);

            var contentType = new ContentType(-1);

            contentType.Name      = contentTypeName;
            contentType.Alias     = contentTypeAlias;
            contentType.Thumbnail = string.Empty;
            contentTypeService.Save(contentType);
            Assert.Greater(contentType.Id, 0);

            var definitions = dataTypeService.GetDataTypeDefinitionByControlId(new Guid("38b352c1-e9f8-4fd8-9324-9a2eab06d97a"));

            dataTypeService.Save(definitions.FirstOrDefault());
            var propertyType = new PropertyType(definitions.FirstOrDefault());

            propertyType.Alias = ContentTypeProperty;
            contentType.AddPropertyType(propertyType);
            contentTypeService.Save(contentType);
            Assert.Greater(contentType.Id, 0);

            var content = new Content(name, -1, contentType);

            content.Key = new Guid("{5928EFBB-6DF2-4BB6-A026-BF4938D7ED7A}");
            content.SetPropertyValue(ContentTypeProperty, fieldValue);
            _contentService.Save(content);
        }
Exemple #12
0
        public override void Up()
        {
            //Create a new Data Type called "Videolizer"

            //Thanks to Sebastiaan Janssen for the code to detect UaaS / Umbraco Cloud - https://our.umbraco.com/forum/umbraco-7/developing-umbraco-7-packages/72572-detecting-if-you-are-running-on-umbraco-as-a-service
            var onUaaS = AppDomain.CurrentDomain.GetAssemblies()
                         .Any(a => a.FullName.StartsWith("Umbraco.Deploy"));

            if (!onUaaS)
            {
                DataTypeService dataTypeService = (DataTypeService)ApplicationContext.Current.Services.DataTypeService;

                if (dataTypeService.GetDataTypeDefinitionByName("Videolizer") == null)
                { //check to see if it already exists
                  //Create a new one
                    DataTypeDefinition VideolizerDataTypeDef = new DataTypeDefinition("DigitalMomentum.Videolizer");
                    VideolizerDataTypeDef.Name = "Videolizer";

                    dataTypeService.Save(VideolizerDataTypeDef);
                }
            }
        }
Exemple #13
0
        public void CreateStub()
        {
            string name             = "Target";
            string contentTypeAlias = "TestType";
            string contentTypeName  = "Test Type";

            var unitOfWork  = Global.CreateUnitOfWork();
            var repoFactory = new RepositoryFactory();

            _contentService = new ContentService(unitOfWork, repoFactory);
            var contentTypeService = new ContentTypeService(unitOfWork, repoFactory,
                                                            new ContentService(unitOfWork),
                                                            new MediaService(unitOfWork, repoFactory));
            var dataTypeService = new DataTypeService(unitOfWork, repoFactory);

            var contentType = new ContentType(-1);

            contentType.Name      = contentTypeName;
            contentType.Alias     = contentTypeAlias;
            contentType.Thumbnail = string.Empty;
            contentTypeService.Save(contentType);
            Assert.Greater(contentType.Id, 0);

            var definitions = dataTypeService.GetDataTypeDefinitionByControlId(new Guid("ec15c1e5-9d90-422a-aa52-4f7622c63bea"));

            dataTypeService.Save(definitions.FirstOrDefault());
            var propertyType = new PropertyType(definitions.FirstOrDefault());

            propertyType.Alias = "Property";
            contentType.AddPropertyType(propertyType);
            contentTypeService.Save(contentType);
            Assert.Greater(contentType.Id, 0);

            var content = new Content(name, -1, contentType);

            content.Key = new Guid("{2867D837-B258-4DF1-90F1-D5E849FCAF84}");
            _contentService.Save(content);
        }
Exemple #14
0
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            var dataType = (DataTypeSave)actionContext.ActionArguments["dataType"];

            dataType.Name  = dataType.Name.CleanForXss('[', ']', '(', ')', ':');
            dataType.Alias = dataType.Alias == null ? dataType.Name : dataType.Alias.CleanForXss('[', ']', '(', ')', ':');

            // get the property editor, ensuring that it exits
            if (!PropertyEditors.TryGet(dataType.EditorAlias, out var propertyEditor))
            {
                var message = $"Property editor \"{dataType.EditorAlias}\" was not found.";
                actionContext.Response = actionContext.Request.CreateErrorResponse(HttpStatusCode.NotFound, message);
                return;
            }

            // assign
            dataType.PropertyEditor = propertyEditor;

            // validate that the data type exists, or create one if required
            IDataType persisted;

            switch (dataType.Action)
            {
            case ContentSaveAction.Save:
                persisted = DataTypeService.GetDataType(Convert.ToInt32(dataType.Id));
                if (persisted == null)
                {
                    var message = $"Data type with id {dataType.Id} was not found.";
                    actionContext.Response = actionContext.Request.CreateErrorResponse(HttpStatusCode.NotFound, message);
                    return;
                }
                // map the model to the persisted instance
                Current.Mapper.Map(dataType, persisted);
                break;

            case ContentSaveAction.SaveNew:
                // create the persisted model from mapping the saved model
                persisted = Current.Mapper.Map <IDataType>(dataType);
                ((DataType)persisted).ResetIdentity();
                break;

            default:
                actionContext.Response = actionContext.Request.CreateErrorResponse(HttpStatusCode.NotFound, new ArgumentOutOfRangeException());
                return;
            }

            // assign (so it's available in the action)
            dataType.PersistedDataType = persisted;

            // validate the configuration
            // which is posted as a set of fields with key (string) and value (object)
            var configurationEditor = propertyEditor.GetConfigurationEditor();

            foreach (var field in dataType.ConfigurationFields)
            {
                var editorField = configurationEditor.Fields.SingleOrDefault(x => x.Key == field.Key);
                if (editorField == null)
                {
                    continue;
                }

                // run each IValueValidator (with null valueType and dataTypeConfiguration: not relevant here)
                foreach (var validator in editorField.Validators)
                {
                    foreach (var result in validator.Validate(field.Value, null, null))
                    {
                        actionContext.ModelState.AddValidationError(result, "Properties", field.Key);
                    }
                }
            }

            if (actionContext.ModelState.IsValid == false)
            {
                // if it is not valid, do not continue and return the model state
                actionContext.Response = actionContext.Request.CreateValidationErrorResponse(actionContext.ModelState);
            }
        }
Exemple #15
0
        public void General_RetrieveContentAndPropertiesFromUmbraco_ReturnPopulatedClass()
        {
            //Assign
            string fieldValue          = "test field value";
            string name                = "Target";
            string contentTypeAlias    = "TestType";
            string contentTypeName     = "Test Type";
            string contentTypeProperty = "TestProperty";

            var unitOfWork         = Global.CreateUnitOfWork();
            var repoFactory        = new RepositoryFactory();
            var contentService     = new ContentService(unitOfWork, repoFactory);
            var contentTypeService = new ContentTypeService(unitOfWork, repoFactory,
                                                            new ContentService(unitOfWork),
                                                            new MediaService(unitOfWork, repoFactory));
            var dataTypeService = new DataTypeService(unitOfWork, repoFactory);
            var context         = WindsorContainer.GetContext();

            var loader     = new UmbracoFluentConfigurationLoader();
            var stubConfig = loader.Add <Stub>();

            stubConfig.Configure(x =>
            {
                x.Id(y => y.Id);
                x.Id(y => y.Key);
                x.Property(y => y.TestProperty);
                x.Info(y => y.Name).InfoType(UmbracoInfoType.Name);
                x.Info(y => y.ContentTypeName).InfoType(UmbracoInfoType.ContentTypeName);
                x.Info(y => y.ContentTypeAlias).InfoType(UmbracoInfoType.ContentTypeAlias);
                x.Info(y => y.Path).InfoType(UmbracoInfoType.Path);
                x.Info(y => y.Version).InfoType(UmbracoInfoType.Version);
                x.Info(y => y.CreateDate).InfoType(UmbracoInfoType.CreateDate);
                x.Info(y => y.UpdateDate).InfoType(UmbracoInfoType.UpdateDate);
                x.Info(y => y.Creator).InfoType(UmbracoInfoType.Creator);
                x.Delegate(y => y.Delegated).GetValue(GetDelegatedValue);
            });

            context.Load(loader);

            IContentType contentType = new ContentType(-1);

            contentType.Name      = contentTypeName;
            contentType.Alias     = contentTypeAlias;
            contentType.Thumbnail = string.Empty;
            contentTypeService.Save(contentType);
            Assert.Greater(contentType.Id, 0);

            var definitions = dataTypeService.GetDataTypeDefinitionByControlId(new Guid("ec15c1e5-9d90-422a-aa52-4f7622c63bea"));

            dataTypeService.Save(definitions.FirstOrDefault());
            var propertyType = new PropertyType(definitions.FirstOrDefault());

            propertyType.Alias = contentTypeProperty;
            contentType.AddPropertyType(propertyType);
            contentTypeService.Save(contentType);
            Assert.Greater(contentType.Id, 0);

            var content = new Content(name, -1, contentType);

            content.SetPropertyValue(contentTypeProperty, fieldValue);
            contentService.Save(content);

            var umbracoService = new UmbracoService(contentService, context);

            //Act
            var result = umbracoService.GetItem <Stub>(content.Id);

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(fieldValue, result.TestProperty);
            Assert.AreEqual(content.Id, result.Id);
            Assert.AreEqual(content.Key, result.Key);
            Assert.AreEqual(name, result.Name);
            Assert.AreEqual(contentTypeName, result.ContentTypeName);
            Assert.AreEqual(content.ParentId + "," + content.Id, result.Path);
            Assert.AreEqual(contentTypeAlias, result.ContentTypeAlias);
            Assert.AreEqual(content.Version, result.Version);
            Assert.AreEqual(content.CreateDate, result.CreateDate);
            Assert.AreEqual(content.UpdateDate, result.UpdateDate);
            Assert.AreEqual("admin", result.Creator);
            Assert.AreEqual("happy", result.Delegated);
        }
Exemple #16
0
        public void Process(IEnumerable <DocumentTypeMetadata> types)
        {
            var contentTypes        = new List <IContentType>();
            var dataTypeDefinitions = DataTypeService.GetAllDataTypeDefinitions().ToArray();

            foreach (var type in types)
            {
                var ct = ContentTypeService.GetContentType(type.Alias) ?? new ContentType(-1);

                ct.Name          = type.Name;
                ct.Alias         = type.Alias;
                ct.AllowedAsRoot = type.AllowAsRoot;
                ct.Description   = type.Description;
                ct.Icon          = type.Icon;
                ct.Thumbnail     = type.Thumbnail;

                var properties = ct.PropertyTypes.ToArray();

                var newProperties = type.Properties.Where(p => !properties.Any(x => x.Alias == p.Alias));

                foreach (var property in newProperties)
                {
                    var p = new PropertyType(dataTypeDefinitions.First(dtd => dtd.Name == property.DataType))
                    {
                        Name        = property.Name,
                        Alias       = property.Alias,
                        Description = property.Description
                    };

                    if (property.Tab == null)
                    {
                        ct.AddPropertyType(p);
                    }
                    else
                    {
                        ct.AddPropertyType(p, property.Tab.ToString());
                    }
                }

                var modifiedProperties = type.Properties.Join(properties, p => p.Alias, p => p.Alias, (meta, p) => new
                {
                    Metadata     = meta,
                    PropertyType = p
                });

                foreach (var property in modifiedProperties)
                {
                    var p    = property.PropertyType;
                    var meta = property.Metadata;

                    p.Name = meta.Name;
                    p.DataTypeDefinitionId = dataTypeDefinitions.First(dtd => dtd.Name == meta.DataType).Id;
                    p.Description          = meta.Description;

                    //the following hack is brought to you be the letter F
                    var fn = p.GetType().GetProperty("PropertyGroupId", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(p) as System.Lazy <int>;
                    if (fn != null)
                    {
                        var tabId      = fn.Value;
                        var tab        = ct.PropertyGroups.FirstOrDefault(t => t.Id == tabId);
                        var newTabName = meta.Tab.ToString();
                        var newTab     = ct.PropertyGroups.FirstOrDefault(t => t.Name == newTabName);

                        if (tab != null && tab.Name != newTabName)
                        {
                            if (newTab == null)
                            {
                                ct.AddPropertyGroup(newTabName);
                            }

                            ct.MovePropertyType(p.Alias, newTabName);
                        }
                    }
                }

                contentTypes.Add(ct);
            }

            ContentTypeService.Save(contentTypes);

            var preprocessedData = contentTypes
                                   .Join(types, x => x.Alias, x => x.Alias, (ct, m) => new { ct, m })
                                   .ToDictionary(x => x.ct, x => x.m);

            SetupAllowedChildren(preprocessedData);
            SetupTemplates(preprocessedData);

            ContentTypeService.Save(contentTypes);
        }
Exemple #17
0
        public static void AddSocialMediaChannelMediaType()
        {
            MediaType mediaType = new MediaType(-1);

            mediaType.AllowedAsRoot = true;
            mediaType.Name          = SOCIAL_MEDIA_THEME_NAME;
            mediaType.Description   = "Container for the Social Media Channel Theme Images";
            mediaType.IsContainer   = true;
            mediaType.Icon          = "icon-picture";
            mediaType.Alias         = SOCIAL_MEDIA_THEME_ALIAS;

            //Allowed child nodes
            var children = new List <ContentTypeSort>
            {
                new ContentTypeSort(FOLDER_ID, 0),
                new ContentTypeSort(IMAGE_ID, 1)
            };

            mediaType.AllowedContentTypes = children;


            //Add properties
            DataTypeService dataTypeService = (DataTypeService)ApplicationContext.Current.Services.DataTypeService;

            var name = new PropertyType(dataTypeService.GetDataTypeDefinitionById(TEXT_ID), "themeName");

            name.Name        = "Theme Name";
            name.Description = "Name for the theme";
            name.SortOrder   = 0;

            var url = new PropertyType(dataTypeService.GetDataTypeDefinitionById(TEXT_ID), "themeUrl");

            url.Name        = "Theme Url";
            url.Description = "Url for the original theme";
            url.SortOrder   = 1;

            var createdBy = new PropertyType(dataTypeService.GetDataTypeDefinitionById(TEXT_ID), "createdBy");

            createdBy.Name        = "Created By";
            createdBy.Description = "Theme Author";
            createdBy.SortOrder   = 2;

            var createdDate = new PropertyType(dataTypeService.GetDataTypeDefinitionById(DATE_ID), "createdDate");

            createdDate.Name        = "Created Date";
            createdDate.Description = "Date the Theme was created";
            createdDate.SortOrder   = 3;

            var upload = new PropertyType(dataTypeService.GetDataTypeDefinitionById(UPLOAD_ID), "umbracoFile");

            upload.Name        = "Upload Image";
            upload.Description = "Theme Thumbnail";
            upload.SortOrder   = 4;

            var width = new PropertyType(dataTypeService.GetDataTypeDefinitionById(LABEL_ID), "umbracoWidth");

            width.Name      = "Image Width";
            width.SortOrder = 5;

            var height = new PropertyType(dataTypeService.GetDataTypeDefinitionById(LABEL_ID), "umbracoHeight");

            height.Name      = "Image Height";
            height.SortOrder = 5;

            var size = new PropertyType(dataTypeService.GetDataTypeDefinitionById(LABEL_ID), "umbracoBytes");

            size.Name      = "Image Size";
            size.SortOrder = 5;

            var extension = new PropertyType(dataTypeService.GetDataTypeDefinitionById(LABEL_ID), "umbracoExtension");

            extension.Name      = "Image Extension";
            extension.SortOrder = 5;

            mediaType.AddPropertyType(name, "Theme");
            mediaType.AddPropertyType(url, "Theme");
            mediaType.AddPropertyType(createdBy, "Theme");
            mediaType.AddPropertyType(createdDate, "Theme");
            mediaType.AddPropertyType(upload, "Theme");
            mediaType.AddPropertyType(width, "Theme");
            mediaType.AddPropertyType(height, "Theme");
            mediaType.AddPropertyType(size, "Theme");
            mediaType.AddPropertyType(extension, "Theme");

            //Save new media type
            ContentTypeService contentTypeService = (ContentTypeService)ApplicationContext.Current.Services.ContentTypeService;

            contentTypeService.Save(mediaType);
        }