public ExcelImport(OfficeOpenXml.ExcelWorksheet workSheet, ContentTypeData typeData)
 {
     InitializeComponent();
     this.WorkSheet = workSheet;
     this.TypeData  = typeData;
     Load          += ExcelImport_Load;
 }
Exemple #2
0
        public InitialiseContentCreationBuilder UpdateContentTypes()
        {
            //Usually I wouldnt explcitly instantiate a class here, I would use DI with an IOC container but due to time, I stuck with this
            IContentTypeUpdateService contentTypeUpdateService = new ContentTypeUpdateService(_contentTypeService, _fileService, _dataTypeService);

            var seoContentType  = _contentTypeService.Get("seo");
            var homeContentType = _contentTypeService.Get("home");
            var pageContentType = _contentTypeService.Get("contentPage");

            if (seoContentType != null)
            {
                var contentTypeData = new ContentTypeData()
                {
                    Properties = new PropertyTypeData[] { new PropertyTypeData("Page Title", "pageTitle", "Textstring", "SEO") }
                };

                contentTypeUpdateService.Update(seoContentType, contentTypeData);
            }

            if (homeContentType != null)
            {
                var contentTypeData = new ContentTypeData()
                {
                    Template   = "Home",
                    Composites = new string[] { "seo" },
                    Properties = new PropertyTypeData[] { new PropertyTypeData("Body", "body", "Richtext editor", "Details") }
                };

                contentTypeUpdateService.Update(homeContentType, contentTypeData);
            }

            if (pageContentType != null)
            {
                var contentTypeData = new ContentTypeData()
                {
                    Template   = "Content Page",
                    Composites = new string[] { "seo" },
                    Properties = new PropertyTypeData[] { new PropertyTypeData("Body", "body", "Richtext editor", "Details") }
                };

                contentTypeUpdateService.Update(pageContentType, contentTypeData);
            }

            contentTypeUpdateService.SetAllowedContentTypes(homeContentType, new IContentType[] { pageContentType });

            return(this);
        }
Exemple #3
0
        public void Update(IContentType contentType, ContentTypeData contentTypeData)
        {
            //Set Composites

            if (contentTypeData.Composites != null)
            {
                foreach (var composite in contentTypeData.Composites)
                {
                    var compositeContentType = _contentTypeService.Get(composite);
                    contentType.AddContentType(compositeContentType);
                }
            }

            //Set Property Types

            if (contentTypeData.Properties != null)
            {
                foreach (var property in contentTypeData.Properties)
                {
                    var dataType = _dataTypeService.GetDataType(property.DataTypeName);

                    var newPropertyType = new PropertyType(dataType, property.Alias);
                    newPropertyType.Name = property.Name;

                    contentType.AddPropertyType(newPropertyType, property.Group);
                }
            }


            //Set Templates
            var masterTemplate = _fileService.GetTemplate("master");

            if (masterTemplate == null)
            {
                masterTemplate = _fileService.CreateTemplateWithIdentity("Master", "master", null);
            }

            if (!string.IsNullOrWhiteSpace(contentTypeData.Template))
            {
                var template = _fileService.CreateTemplateWithIdentity(contentTypeData.Template, contentType.Alias, null, masterTemplate);
                _fileService.SaveTemplate(template);

                contentType.SetDefaultTemplate(template);
            }

            _contentTypeService.Save(contentType);
        }
 public void SetContentfulType(Library.Models.ContentTypeData type)
 {
     this.TypeData = type;
 }
Exemple #5
0
 public void LoadContentType(ContentTypeData contentType, ContentFulRowData rowData)
 {
     this.ContentType = contentType;
     this.RowData     = rowData;
     LoadFields();
 }
Exemple #6
0
 public void LoadContentType(ContentTypeData contentType)
 {
     this.ContentType = contentType;
     LoadFields();
     RowData = null;
 }