/// <summary> /// Creates a new datatypedefinition given its name and the user which creates it. /// </summary> /// <param name="u">The user who creates the datatypedefinition</param> /// <param name="Text">The name of the DataTypeDefinition</param> /// <param name="UniqueId">Overrides the CMSnodes uniqueID</param> /// <returns></returns> public static DataTypeDefinition MakeNew(BusinessLogic.User u, string Text, Guid UniqueId) { int newId = CMSNode.MakeNew(-1, _objectType, u.Id, 1, Text, UniqueId).Id; cms.businesslogic.datatype.controls.Factory f = new cms.businesslogic.datatype.controls.Factory(); // initial control id changed to empty to ensure that it'll always work no matter if 3rd party configurators fail // ref: http://umbraco.codeplex.com/workitem/29788 Guid FirstcontrolId = Guid.Empty; SqlHelper.ExecuteNonQuery("Insert into cmsDataType (nodeId, controlId, dbType) values (" + newId.ToString() + ",@controlId,'Ntext')", SqlHelper.CreateParameter("@controlId", FirstcontrolId)); DataTypeDefinition dtd = new DataTypeDefinition(newId); dtd.OnNew(EventArgs.Empty); return(dtd); }
/// <summary> /// Creates a new datatypedefinition given its name and the user which creates it. /// </summary> /// <param name="u">The user who creates the datatypedefinition</param> /// <param name="Text">The name of the DataTypeDefinition</param> /// <param name="UniqueId">Overrides the CMSnodes uniqueID</param> /// <returns></returns> public static DataTypeDefinition MakeNew(BusinessLogic.User u, string Text, Guid UniqueId) { var found = ApplicationContext.Current.Services.DataTypeService.GetDataTypeDefinitionByName(Text); if (found != null) { throw new DuplicateNameException("A data type with the name " + Text + " already exists"); } var created = new Umbraco.Core.Models.DataTypeDefinition("") { Name = Text, Key = UniqueId }; ApplicationContext.Current.Services.DataTypeService.Save(created); var dtd = new DataTypeDefinition(created); dtd.OnNew(EventArgs.Empty); return(dtd); }
/// <summary> /// Creates a new datatypedefinition given its name and the user which creates it. /// </summary> /// <param name="u">The user who creates the datatypedefinition</param> /// <param name="Text">The name of the DataTypeDefinition</param> /// <param name="UniqueId">Overrides the CMSnodes uniqueID</param> /// <returns></returns> public static DataTypeDefinition MakeNew(BusinessLogic.User u, string Text, Guid UniqueId) { int newId = CMSNode.MakeNew(-1, _objectType, u.Id, 1, Text, UniqueId).Id; cms.businesslogic.datatype.controls.Factory f = new cms.businesslogic.datatype.controls.Factory(); // initial control id changed to empty to ensure that it'll always work no matter if 3rd party configurators fail // ref: http://umbraco.codeplex.com/workitem/29788 Guid FirstcontrolId = Guid.Empty; SqlHelper.ExecuteNonQuery("Insert into cmsDataType (nodeId, controlId, dbType) values (" + newId.ToString() + ",@controlId,'Ntext')", SqlHelper.CreateParameter("@controlId", FirstcontrolId)); DataTypeDefinition dtd = new DataTypeDefinition(newId); dtd.OnNew(EventArgs.Empty); return dtd; }
/// <summary> /// Creates a new datatypedefinition given its name and the user which creates it. /// </summary> /// <param name="u">The user who creates the datatypedefinition</param> /// <param name="Text">The name of the DataTypeDefinition</param> /// <param name="UniqueId">Overrides the CMSnodes uniqueID</param> /// <returns></returns> public static DataTypeDefinition MakeNew(BusinessLogic.User u, string Text, Guid UniqueId) { var newId = MakeNew(-1, ObjectType, u.Id, 1, Text, UniqueId).Id; //insert empty prop ed alias SqlHelper.ExecuteNonQuery("Insert into cmsDataType (nodeId, propertyEditorAlias, dbType) values (" + newId + ",'','Ntext')"); var dtd = new DataTypeDefinition(newId); dtd.OnNew(EventArgs.Empty); return dtd; }