/// <summary>
 /// Accesses the <see cref="DocumentTypeAttribute"/> applied to a class to find
 /// the document type alias for that class
 /// </summary>
 /// <param name="input">The document type instance to get the alias for</param>
 /// <returns>the document type alias</returns>
 /// <exception cref="CodeFirstException">Thrown if the specified type does not have a <see cref="DocumentTypeAttribute"/> attribute.</exception>
 public static string GetDocumentTypeAlias(this DocumentTypeBase input)
 {
     try
     {
         return(input.GetType().GetCodeFirstAttribute <DocumentTypeAttribute>().Alias);
     }
     catch (Exception e)
     {
         throw new CodeFirstException(input.GetType().Name, e);
     }
 }
        public void ProjectModelToContent(DocumentTypeBase model, IContent content)
        {
            var type = model.GetType();
            DocumentTypeRegistration reg;

            if (_documentTypeModule.TryGetDocumentType(type, out reg) && (reg.ClrType == type || reg.ClrType.Inherits(type)))
            {
                MapModelToContent(content, model, reg);
            }
        }
        public IContent ConvertToContent(DocumentTypeBase model, int parentId = -1)
        {
            var contentId = model.NodeDetails.UmbracoId;
            DocumentTypeRegistration registration;

            if (!_documentTypeModule.TryGetDocumentType(model.GetType(), out registration))
            {
                throw new CodeFirstException("Document type not registered. Type: " + model.GetType());
            }

            //Create or update object
            if (contentId == -1)
            {
                return(CreateContent(parentId, model, registration));
            }
            else
            {
                return(UpdateContent(model, registration));
            }
        }