private static IContent CreateContent(ContentRequest contentRequest, DivvyTypeMapping mapping)
        {
            // Run the event. The target node might change in here
            var e = new DivvyEventArgs()
            {
                ContentRequest   = contentRequest,
                IntendedParent   = mapping.ParentNode,
                IntendedTypeName = mapping.EpiserverPageTypeName
            };

            OnBeforeContentCreation(null, e);

            if (e.CancelAction)
            {
                return(null);
            }

            var parent = repo.Get <PageData>(e.IntendedParent);

            DivvyLogManager.LogRequest($"Creating New Content", new { Type = e.IntendedTypeName, ParentId = parent.ContentGuid, ParentName = parent.Name });

            try
            {
                // Get the type ID. For whatever reason, we can't create content with a type name, we have to have the ID...
                var type = typeRepo.Load(e.IntendedTypeName);

                // Create the content
                var content = repo.GetDefault <IContent>(e.IntendedParent, type.ID);
                content.Name = contentRequest.Title;
                repo.Save(content, AccessLevel.NoAccess);

                // There's an edge case where we have a mappng already because the Episerver content got deleted
                if (!DivvyContentMapping.HasDivvyMapping(content.ContentLink.ID))
                {
                    DivvyContentMapping.Create(content.ContentLink.ID, contentRequest.Id);
                }

                DivvyLogManager.LogRequest("Created New Content", new { Id = content.ContentGuid });

                return(content);
            }
            catch (Exception ex)
            {
                DivvyLogManager.LogRequest($"Error Creating New Content", ex);
                return(null);
            }
        }
 public static void AddMapping(DivvyTypeMapping mapping)
 {
     typeMappings.Add(mapping);
 }