diff --git a/src/Umbraco.Core/Constants-ObjectTypes.cs b/src/Umbraco.Core/Constants-ObjectTypes.cs
index f737a68f02..272c7b6215 100644
--- a/src/Umbraco.Core/Constants-ObjectTypes.cs
+++ b/src/Umbraco.Core/Constants-ObjectTypes.cs
@@ -9,6 +9,11 @@ namespace Umbraco.Core
///
public static class ObjectTypes
{
+ ///
+ /// Guid for a member type container
+ ///
+ public const string MemberTypeContainer = "02348110-FC53-4565-9B01-0E186B6B9E7C";
+
///
/// Guid for a doc type container
///
@@ -102,6 +107,8 @@ namespace Umbraco.Core
/// Guid for a Lock object.
///
public const string LockObject = "87A9F1FF-B1E4-4A25-BABB-465A4A47EC41";
+
+
}
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Models/EntityContainer.cs b/src/Umbraco.Core/Models/EntityContainer.cs
new file mode 100644
index 0000000000..9c890fd594
--- /dev/null
+++ b/src/Umbraco.Core/Models/EntityContainer.cs
@@ -0,0 +1,17 @@
+using Umbraco.Core.Models.EntityBase;
+
+namespace Umbraco.Core.Models
+{
+ ///
+ /// Represents a folder for organizing entities such as content types and data types
+ ///
+ public sealed class EntityContainer : UmbracoEntity, IAggregateRoot
+ {
+ public EntityContainer(int parentId, string name, int userId)
+ {
+ ParentId = parentId;
+ Name = name;
+ CreatorId = userId;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Models/UmbracoEntity.cs b/src/Umbraco.Core/Models/UmbracoEntity.cs
index 4975ad3bd2..70ef056068 100644
--- a/src/Umbraco.Core/Models/UmbracoEntity.cs
+++ b/src/Umbraco.Core/Models/UmbracoEntity.cs
@@ -11,7 +11,7 @@ namespace Umbraco.Core.Models
///
/// Implementation of the for internal use.
///
- internal class UmbracoEntity : Entity, IUmbracoEntity
+ public class UmbracoEntity : Entity, IUmbracoEntity
{
private int _creatorId;
private int _level;
diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs
index c75c061452..d25fab2cb7 100644
--- a/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs
@@ -28,72 +28,35 @@ namespace Umbraco.Core.Persistence.Repositories
where TEntity : class, IContentTypeComposition
{
- protected ContentTypeBaseRepository(IDatabaseUnitOfWork work, CacheHelper cache, ILogger logger, ISqlSyntaxProvider sqlSyntax)
+ protected ContentTypeBaseRepository(IDatabaseUnitOfWork work, CacheHelper cache, ILogger logger, ISqlSyntaxProvider sqlSyntax,
+ Guid containerType)
: base(work, cache, logger, sqlSyntax)
{
_guidRepo = new GuidReadOnlyContentTypeBaseRepository(this, work, cache, logger, sqlSyntax);
+ _containerRepository = new EntityContainerRepository(work, cache, logger, sqlSyntax, containerType, NodeObjectTypeId);
}
+ private readonly EntityContainerRepository _containerRepository;
private readonly GuidReadOnlyContentTypeBaseRepository _guidRepo;
-
+
///
- /// The container object type - used for organizing content types
+ /// Deletes a folder - this will move all contained content types into their parent
///
- protected abstract Guid ContainerObjectTypeId { get; }
-
- public Attempt CreateFolder(int parentId, string name, int userId)
+ ///
+ ///
+ /// Returns the content types moved
+ ///
+ public void DeleteFolder(int folderId)
{
- name = name.Trim();
+ var found = _containerRepository.Get(folderId);
+ _containerRepository.Delete(found);
+ }
- Mandate.ParameterNotNullOrEmpty(name, "name");
-
- var exists = Database.FirstOrDefault(
- new Sql().Select("*")
- .From(SqlSyntax)
- .Where(dto => dto.ParentId == parentId && dto.Text == name && dto.NodeObjectType == ContainerObjectTypeId));
-
- if (exists != null)
- {
- return Attempt.Fail(exists.NodeId, new InvalidOperationException("A folder with the same name already exists"));
- }
-
- var level = 0;
- var path = "-1";
- if (parentId > -1)
- {
- var parent = Database.FirstOrDefault(
- new Sql().Select("*")
- .From(SqlSyntax)
- .Where(dto => dto.NodeId == parentId && dto.NodeObjectType == ContainerObjectTypeId));
-
- if (parent == null)
- {
- return Attempt.Fail(0, new NullReferenceException("No content type container found with parent id " + parentId));
- }
- level = parent.Level;
- path = parent.Path;
- }
-
- var folder = new NodeDto
- {
- CreateDate = DateTime.Now,
- Level = Convert.ToInt16(level + 1),
- NodeObjectType = ContainerObjectTypeId,
- ParentId = parentId,
- Path = path,
- SortOrder = 0,
- Text = name,
- Trashed = false,
- UniqueId = Guid.NewGuid(),
- UserId = userId
- };
-
- Database.Save(folder);
- //update the path
- folder.Path = folder.Path + "," + folder.NodeId;
- Database.Save(folder);
-
- return Attempt.Succeed(folder.NodeId);
+ public EntityContainer CreateFolder(int parentId, string name, int userId)
+ {
+ var container = new EntityContainer(parentId, name, userId);
+ _containerRepository.AddOrUpdate(container);
+ return container;
}
///
@@ -105,15 +68,15 @@ namespace Umbraco.Core.Persistence.Repositories
{
var sqlClause = new Sql();
sqlClause.Select("*")
- .From()
- .RightJoin()
- .On(left => left.Id, right => right.PropertyTypeGroupId)
- .InnerJoin()
- .On(left => left.DataTypeId, right => right.DataTypeId);
+ .From(SqlSyntax)
+ .RightJoin(SqlSyntax)
+ .On(SqlSyntax, left => left.Id, right => right.PropertyTypeGroupId)
+ .InnerJoin(SqlSyntax)
+ .On(SqlSyntax, left => left.DataTypeId, right => right.DataTypeId);
var translator = new SqlTranslator(sqlClause, query);
var sql = translator.Translate()
- .OrderBy(x => x.PropertyTypeGroupId);
+ .OrderBy(x => x.PropertyTypeGroupId, SqlSyntax);
var dtos = Database.Fetch(new GroupPropertyTypeRelator().Map, sql);
diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs
index ab22b66679..4145cb89b4 100644
--- a/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs
@@ -22,7 +22,7 @@ namespace Umbraco.Core.Persistence.Repositories
private readonly ITemplateRepository _templateRepository;
public ContentTypeRepository(IDatabaseUnitOfWork work, CacheHelper cache, ILogger logger, ISqlSyntaxProvider sqlSyntax, ITemplateRepository templateRepository)
- : base(work, cache, logger, sqlSyntax)
+ : base(work, cache, logger, sqlSyntax, new Guid(Constants.ObjectTypes.DocumentTypeContainer))
{
_templateRepository = templateRepository;
}
@@ -96,11 +96,11 @@ namespace Umbraco.Core.Persistence.Repositories
var sql = new Sql();
sql.Select(isCount ? "COUNT(*)" : "*")
- .From()
- .InnerJoin()
- .On(left => left.NodeId, right => right.NodeId)
- .LeftJoin()
- .On(left => left.ContentTypeNodeId, right => right.NodeId)
+ .From(SqlSyntax)
+ .InnerJoin(SqlSyntax)
+ .On(SqlSyntax, left => left.NodeId, right => right.NodeId)
+ .LeftJoin(SqlSyntax)
+ .On(SqlSyntax ,left => left.ContentTypeNodeId, right => right.NodeId)
.Where(x => x.NodeObjectType == NodeObjectTypeId);
return sql;
@@ -241,14 +241,7 @@ namespace Umbraco.Core.Persistence.Repositories
}
#endregion
-
- ///
- /// The container object type - used for organizing content types
- ///
- protected override Guid ContainerObjectTypeId
- {
- get { return new Guid(Constants.ObjectTypes.DocumentTypeContainer); }
- }
+
protected override IContentType PerformGet(Guid id)
{
diff --git a/src/Umbraco.Core/Persistence/Repositories/EntityContainerRepository.cs b/src/Umbraco.Core/Persistence/Repositories/EntityContainerRepository.cs
new file mode 100644
index 0000000000..e1dbc3ef8f
--- /dev/null
+++ b/src/Umbraco.Core/Persistence/Repositories/EntityContainerRepository.cs
@@ -0,0 +1,152 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Umbraco.Core.Logging;
+using Umbraco.Core.Models;
+using Umbraco.Core.Models.Rdbms;
+using Umbraco.Core.Persistence.Querying;
+using Umbraco.Core.Persistence.SqlSyntax;
+using Umbraco.Core.Persistence.UnitOfWork;
+
+namespace Umbraco.Core.Persistence.Repositories
+{
+ ///
+ /// An internal repository for managing entity containers such as doc type, media type, data type containers
+ ///
+ ///
+ /// All we're supporting here is creating and deleting
+ ///
+ internal class EntityContainerRepository : PetaPocoRepositoryBase
+ {
+ private readonly Guid _containerObjectType;
+ private readonly Guid _entityObjectType;
+
+ public EntityContainerRepository(IDatabaseUnitOfWork work, CacheHelper cache, ILogger logger, ISqlSyntaxProvider sqlSyntax,
+ Guid containerObjectType, Guid entityObjectType)
+ : base(work, cache, logger, sqlSyntax)
+ {
+ _containerObjectType = containerObjectType;
+ _entityObjectType = entityObjectType;
+ }
+
+ protected override EntityContainer PerformGet(int id)
+ {
+ throw new NotImplementedException();
+ }
+
+ protected override IEnumerable PerformGetAll(params int[] ids)
+ {
+ throw new NotImplementedException();
+ }
+
+ protected override IEnumerable PerformGetByQuery(IQuery query)
+ {
+ throw new NotImplementedException();
+ }
+
+ protected override Sql GetBaseQuery(bool isCount)
+ {
+ throw new NotImplementedException();
+ }
+
+ protected override string GetBaseWhereClause()
+ {
+ throw new NotImplementedException();
+ }
+
+ protected override IEnumerable GetDeleteClauses()
+ {
+ throw new NotImplementedException();
+ }
+
+ protected override Guid NodeObjectTypeId
+ {
+ get { return _containerObjectType; }
+ }
+
+ protected override void PersistDeletedItem(EntityContainer entity)
+ {
+ var exists = Database.FirstOrDefault(
+ new Sql().Select("*")
+ .From(SqlSyntax)
+ .Where(dto => dto.NodeId == entity.Id && dto.NodeObjectType == _containerObjectType));
+
+ if (exists == null) return;
+
+ //We need to move the content types and folders that exist under this folder to it's parent folder
+ var children = Database.Fetch(
+ new Sql().Select("*")
+ .From(SqlSyntax)
+ .Where(dto => dto.ParentId == entity.Id && (dto.NodeObjectType == _entityObjectType || dto.NodeObjectType == _containerObjectType)));
+
+ foreach (var childDto in children)
+ {
+ childDto.ParentId = exists.ParentId;
+ Database.Update(childDto);
+ }
+
+ //now that everything is moved up a level, we need to delete the container
+ Database.Delete(exists);
+ }
+
+ protected override void PersistNewItem(EntityContainer entity)
+ {
+ entity.Name = entity.Name.Trim();
+
+ Mandate.ParameterNotNullOrEmpty(entity.Name, "entity.Name");
+
+ var exists = Database.FirstOrDefault(
+ new Sql().Select("*")
+ .From(SqlSyntax)
+ .Where(dto => dto.ParentId == entity.ParentId && dto.Text == entity.Name && dto.NodeObjectType == _containerObjectType));
+
+ if (exists != null)
+ {
+ throw new InvalidOperationException("A folder with the same name already exists");
+ }
+
+ var level = 0;
+ var path = "-1";
+ if (entity.ParentId > -1)
+ {
+ var parent = Database.FirstOrDefault(
+ new Sql().Select("*")
+ .From(SqlSyntax)
+ .Where(dto => dto.NodeId == entity.ParentId && dto.NodeObjectType == _containerObjectType));
+
+ if (parent == null)
+ {
+ throw new NullReferenceException("No content type container found with parent id " + entity.ParentId);
+ }
+ level = parent.Level;
+ path = parent.Path;
+ }
+
+ var nodeDto = new NodeDto
+ {
+ CreateDate = DateTime.Now,
+ Level = Convert.ToInt16(level + 1),
+ NodeObjectType = _containerObjectType,
+ ParentId = entity.ParentId,
+ Path = path,
+ SortOrder = 0,
+ Text = entity.Name,
+ Trashed = false,
+ UniqueId = Guid.NewGuid(),
+ UserId = entity.CreatorId
+ };
+
+ Database.Save(nodeDto);
+ //update the path
+ nodeDto.Path = nodeDto.Path + "," + nodeDto.NodeId;
+ Database.Save(nodeDto);
+
+ entity.ResetDirtyProperties();
+ }
+
+ protected override void PersistUpdatedItem(EntityContainer entity)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Persistence/Repositories/Interfaces/IContentTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IContentTypeRepository.cs
index 245552e422..3ea5a2a20d 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Interfaces/IContentTypeRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IContentTypeRepository.cs
@@ -20,6 +20,19 @@ namespace Umbraco.Core.Persistence.Repositories
///
IEnumerable GetAllPropertyTypeAliases();
- Attempt CreateFolder(int parentId, string name, int userId);
+ ///
+ /// Creates a folder for content types
+ ///
+ ///
+ ///
+ ///
+ ///
+ EntityContainer CreateFolder(int parentId, string name, int userId);
+
+ ///
+ /// Deletes a folder - this will move all contained content types into their parent
+ ///
+ ///
+ void DeleteFolder(int folderId);
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Persistence/Repositories/Interfaces/IMediaTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IMediaTypeRepository.cs
index d28c59ac5b..f2b7593c5e 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Interfaces/IMediaTypeRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IMediaTypeRepository.cs
@@ -13,5 +13,20 @@ namespace Umbraco.Core.Persistence.Repositories
///
/// An enumerable list of objects
IEnumerable GetByQuery(IQuery query);
+
+ ///
+ /// Creates a folder for content types
+ ///
+ ///
+ ///
+ ///
+ ///
+ EntityContainer CreateFolder(int parentId, string name, int userId);
+
+ ///
+ /// Deletes a folder - this will move all contained content types into their parent
+ ///
+ ///
+ void DeleteFolder(int folderId);
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Persistence/Repositories/MediaTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/MediaTypeRepository.cs
index 3bf70f1135..70423bb509 100644
--- a/src/Umbraco.Core/Persistence/Repositories/MediaTypeRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/MediaTypeRepository.cs
@@ -20,7 +20,7 @@ namespace Umbraco.Core.Persistence.Repositories
{
public MediaTypeRepository(IDatabaseUnitOfWork work, CacheHelper cache, ILogger logger, ISqlSyntaxProvider sqlSyntax)
- : base(work, cache, logger, sqlSyntax)
+ : base(work, cache, logger, sqlSyntax, new Guid(Constants.ObjectTypes.MediaTypeContainer))
{
}
@@ -43,7 +43,7 @@ namespace Umbraco.Core.Persistence.Repositories
}
else
{
- var sql = new Sql().Select("id").From().Where(dto => dto.NodeObjectType == NodeObjectTypeId);
+ var sql = new Sql().Select("id").From(SqlSyntax).Where(dto => dto.NodeObjectType == NodeObjectTypeId);
var allIds = Database.Fetch(sql).ToArray();
return ContentTypeQueryMapper.GetMediaTypes(allIds, Database, SqlSyntax, this);
}
@@ -54,7 +54,7 @@ namespace Umbraco.Core.Persistence.Repositories
var sqlClause = GetBaseQuery(false);
var translator = new SqlTranslator(sqlClause, query);
var sql = translator.Translate()
- .OrderBy(x => x.Text);
+ .OrderBy(x => x.Text, SqlSyntax);
var dtos = Database.Fetch(sql);
return dtos.Any()
@@ -84,9 +84,9 @@ namespace Umbraco.Core.Persistence.Repositories
{
var sql = new Sql();
sql.Select(isCount ? "COUNT(*)" : "*")
- .From()
- .InnerJoin()
- .On(left => left.NodeId, right => right.NodeId)
+ .From(SqlSyntax)
+ .InnerJoin(SqlSyntax)
+ .On(SqlSyntax, left => left.NodeId, right => right.NodeId)
.Where(x => x.NodeObjectType == NodeObjectTypeId);
return sql;
}
@@ -165,14 +165,7 @@ namespace Umbraco.Core.Persistence.Repositories
}
#endregion
-
- ///
- /// The container object type - used for organizing content types
- ///
- protected override Guid ContainerObjectTypeId
- {
- get { throw new NotImplementedException(); }
- }
+
protected override IMediaType PerformGet(Guid id)
{
diff --git a/src/Umbraco.Core/Persistence/Repositories/MemberTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/MemberTypeRepository.cs
index 4d2fbe30de..275f976baa 100644
--- a/src/Umbraco.Core/Persistence/Repositories/MemberTypeRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/MemberTypeRepository.cs
@@ -22,7 +22,7 @@ namespace Umbraco.Core.Persistence.Repositories
{
public MemberTypeRepository(IDatabaseUnitOfWork work, CacheHelper cache, ILogger logger, ISqlSyntaxProvider sqlSyntax)
- : base(work, cache, logger, sqlSyntax)
+ : base(work, cache, logger, sqlSyntax, new Guid(Constants.ObjectTypes.MemberTypeContainer))
{
}
@@ -32,7 +32,7 @@ namespace Umbraco.Core.Persistence.Repositories
{
var sql = GetBaseQuery(false);
sql.Where(GetBaseWhereClause(), new { Id = id });
- sql.OrderByDescending(x => x.NodeId);
+ sql.OrderByDescending(x => x.NodeId, SqlSyntax);
var dtos =
Database.Fetch(
@@ -240,15 +240,7 @@ namespace Umbraco.Core.Persistence.Repositories
}
#endregion
-
- ///
- /// The container object type - used for organizing content types
- ///
- protected override Guid ContainerObjectTypeId
- {
- get { throw new NotImplementedException(); }
- }
-
+
///
/// Override so we can specify explicit db type's on any property types that are built-in.
///
diff --git a/src/Umbraco.Core/Services/ContentTypeService.cs b/src/Umbraco.Core/Services/ContentTypeService.cs
index fde2b06d8d..2da2375d7f 100644
--- a/src/Umbraco.Core/Services/ContentTypeService.cs
+++ b/src/Umbraco.Core/Services/ContentTypeService.cs
@@ -41,6 +41,58 @@ namespace Umbraco.Core.Services
_mediaService = mediaService;
}
+ public Attempt CreateContentTypeFolder(int parentId, string name, int userId = 0)
+ {
+ using (var repo = RepositoryFactory.CreateContentTypeRepository(UowProvider.GetUnitOfWork()))
+ {
+ try
+ {
+ var container = repo.CreateFolder(parentId, name, userId);
+ return Attempt.Succeed(container.Id);
+ }
+ catch (Exception ex)
+ {
+ return Attempt.Fail(ex);
+ }
+ //TODO: Audit trail ?
+ }
+ }
+
+ public Attempt CreateMediaTypeFolder(int parentId, string name, int userId = 0)
+ {
+ using (var repo = RepositoryFactory.CreateMediaTypeRepository(UowProvider.GetUnitOfWork()))
+ {
+ try
+ {
+ var container = repo.CreateFolder(parentId, name, userId);
+ return Attempt.Succeed(container.Id);
+ }
+ catch (System.Exception ex)
+ {
+ return Attempt.Fail(ex);
+ }
+ //TODO: Audit trail ?
+ }
+ }
+
+ public void DeleteContentTypeFolder(int folderId, int userId = 0)
+ {
+ using (var repo = RepositoryFactory.CreateContentTypeRepository(UowProvider.GetUnitOfWork()))
+ {
+ repo.DeleteFolder(folderId);
+ //TODO: Audit trail ?
+ }
+ }
+
+ public void DeleteMediaTypeFolder(int folderId, int userId = 0)
+ {
+ using (var repo = RepositoryFactory.CreateMediaTypeRepository(UowProvider.GetUnitOfWork()))
+ {
+ repo.DeleteFolder(folderId);
+ //TODO: Audit trail ?
+ }
+ }
+
///
/// Gets all property type aliases.
///
diff --git a/src/Umbraco.Core/Services/ContentTypeServiceBase.cs b/src/Umbraco.Core/Services/ContentTypeServiceBase.cs
index c0f4a8cdf6..df29012b90 100644
--- a/src/Umbraco.Core/Services/ContentTypeServiceBase.cs
+++ b/src/Umbraco.Core/Services/ContentTypeServiceBase.cs
@@ -15,15 +15,7 @@ namespace Umbraco.Core.Services
: base(provider, repositoryFactory, logger, eventMessagesFactory)
{
}
-
- public Attempt CreateFolder(int parentId, string name, int userId = 0)
- {
- using (var repo = RepositoryFactory.CreateContentTypeRepository(UowProvider.GetUnitOfWork()))
- {
- return repo.CreateFolder(parentId, name, userId);
- }
- }
-
+
///
/// This is called after an content type is saved and is used to update the content xml structures in the database
/// if they are required to be updated.
diff --git a/src/Umbraco.Core/Services/IContentTypeService.cs b/src/Umbraco.Core/Services/IContentTypeService.cs
index a68a5f7a6f..597dc5ac65 100644
--- a/src/Umbraco.Core/Services/IContentTypeService.cs
+++ b/src/Umbraco.Core/Services/IContentTypeService.cs
@@ -17,7 +17,10 @@ namespace Umbraco.Core.Services
///
Attempt ValidateComposition(IContentTypeComposition compo);
- Attempt CreateFolder(int parentId, string name, int userId = 0);
+ Attempt CreateContentTypeFolder(int parentId, string name, int userId = 0);
+ Attempt CreateMediaTypeFolder(int parentId, string name, int userId = 0);
+ void DeleteMediaTypeFolder(int folderId, int userId = 0);
+ void DeleteContentTypeFolder(int folderId, int userId = 0);
///
/// Gets all property type aliases.
diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj
index 499106c9d3..a1682e1449 100644
--- a/src/Umbraco.Core/Umbraco.Core.csproj
+++ b/src/Umbraco.Core/Umbraco.Core.csproj
@@ -357,6 +357,7 @@
+
@@ -443,6 +444,7 @@
+
diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js
index e8b2a2e623..0ba60042bf 100644
--- a/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js
+++ b/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js
@@ -109,7 +109,7 @@ function contentTypeResource($q, $http, umbRequestHelper, umbDataFormatter) {
$http.post(
umbRequestHelper.getApiUrl(
"contentTypeApiBaseUrl",
- "DeleteContainerById",
+ "DeleteContainer",
[{ id: id }])),
'Failed to delete content type contaier');
},
@@ -166,14 +166,14 @@ function contentTypeResource($q, $http, umbRequestHelper, umbDataFormatter) {
'Failed to save data for content type id ' + contentType.id);
},
- createFolder: function(parentId, name) {
+ createContainer: function(parentId, name) {
return umbRequestHelper.resourcePromise(
- $http.post(umbRequestHelper.getApiUrl("contentTypeApiBaseUrl", "PostCreateFolder", { parentId: parentId, name: name })),
+ $http.post(umbRequestHelper.getApiUrl("contentTypeApiBaseUrl", "PostCreateContainer", { parentId: parentId, name: name })),
'Failed to create a folder under parent id ' + parentId);
}
-
+
};
}
angular.module('umbraco.resources').factory('contentTypeResource', contentTypeResource);
diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/mediatype.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/mediatype.resource.js
index 93e7fefa2b..d1c2f0888b 100644
--- a/src/Umbraco.Web.UI.Client/src/common/resources/mediatype.resource.js
+++ b/src/Umbraco.Web.UI.Client/src/common/resources/mediatype.resource.js
@@ -88,7 +88,7 @@ function mediaTypeResource($q, $http, umbRequestHelper, umbDataFormatter) {
'Failed to save data for content type id ' + contentType.id);
},
- createFolder: function(parentId, name) {
+ createContainer: function(parentId, name) {
return umbRequestHelper.resourcePromise(
$http.post(
diff --git a/src/Umbraco.Web.UI.Client/src/views/documenttypes/create.controller.js b/src/Umbraco.Web.UI.Client/src/views/documenttypes/create.controller.js
index 4897ad3023..a62024e704 100644
--- a/src/Umbraco.Web.UI.Client/src/views/documenttypes/create.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/documenttypes/create.controller.js
@@ -19,9 +19,9 @@ function DocumentTypesCreateController($scope, $location, navigationService, con
$scope.model.creatingFolder = true;
}
- $scope.createFolder = function () {
+ $scope.createContainer = function () {
if (formHelper.submitForm({ scope: $scope, formCtrl: this.createFolderForm, statusMessage: "Creating folder..." })) {
- contentTypeResource.createFolder(node.id, $scope.model.folderName).then(function (folderId) {
+ contentTypeResource.createContainer(node.id, $scope.model.folderName).then(function (folderId) {
navigationService.hideMenu();
var currPath = node.path ? node.path : "-1";
diff --git a/src/Umbraco.Web.UI.Client/src/views/mediatypes/create.controller.js b/src/Umbraco.Web.UI.Client/src/views/mediatypes/create.controller.js
index d6303ea264..44f615ac7f 100644
--- a/src/Umbraco.Web.UI.Client/src/views/mediatypes/create.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/mediatypes/create.controller.js
@@ -19,9 +19,9 @@ function MediaTypesCreateController($scope, $location, navigationService, mediaT
$scope.model.creatingFolder = true;
}
- $scope.createFolder = function () {
+ $scope.createContainer = function () {
if (formHelper.submitForm({ scope: $scope, formCtrl: this.createFolderForm, statusMessage: "Creating folder..." })) {
- mediaTypeResource.createFolder(node.id, $scope.model.folderName).then(function (folderId) {
+ mediaTypeResource.createContainer(node.id, $scope.model.folderName).then(function (folderId) {
navigationService.hideMenu();
var currPath = node.path ? node.path : "-1";
diff --git a/src/Umbraco.Web.UI.Client/src/views/membertypes/create.controller.js b/src/Umbraco.Web.UI.Client/src/views/membertypes/create.controller.js
index e696bd45d6..2e2d274fe1 100644
--- a/src/Umbraco.Web.UI.Client/src/views/membertypes/create.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/membertypes/create.controller.js
@@ -19,9 +19,9 @@ function MemberTypesCreateController($scope, $location, navigationService, membe
$scope.model.creatingFolder = true;
}
- $scope.createFolder = function () {
+ $scope.createContainer = function () {
if (formHelper.submitForm({ scope: $scope, formCtrl: this.createFolderForm, statusMessage: "Creating folder..." })) {
- memberTypeResource.createFolder(node.id, $scope.model.folderName).then(function (folderId) {
+ memberTypeResource.createContainer(node.id, $scope.model.folderName).then(function (folderId) {
navigationService.hideMenu();
var currPath = node.path ? node.path : "-1";
diff --git a/src/Umbraco.Web/Editors/ContentTypeController.cs b/src/Umbraco.Web/Editors/ContentTypeController.cs
index 6ca5eedff7..d09cfea42c 100644
--- a/src/Umbraco.Web/Editors/ContentTypeController.cs
+++ b/src/Umbraco.Web/Editors/ContentTypeController.cs
@@ -118,29 +118,16 @@ namespace Umbraco.Web.Editors
///
[HttpDelete]
[HttpPost]
- public HttpResponseMessage DeleteContainerById(int id)
+ public HttpResponseMessage DeleteContainer(int id)
{
- //TODO: This needs to be implemented correctly
-
- var foundType = Services.EntityService.Get(id);
- if (foundType == null)
- {
- throw new HttpResponseException(HttpStatusCode.NotFound);
- }
-
- if (foundType.HasChildren())
- {
- throw new HttpResponseException(HttpStatusCode.Forbidden);
- }
-
- //TODO: what service to use to delete?
+ Services.ContentTypeService.DeleteContentTypeFolder(id, Security.CurrentUser.Id);
return Request.CreateResponse(HttpStatusCode.OK);
}
- public HttpResponseMessage PostCreateFolder(int parentId, string name)
+ public HttpResponseMessage PostCreateContainer(int parentId, string name)
{
- var result = Services.ContentTypeService.CreateFolder(parentId, name, Security.CurrentUser.Id);
+ var result = Services.ContentTypeService.CreateContentTypeFolder(parentId, name, Security.CurrentUser.Id);
return result
? Request.CreateResponse(HttpStatusCode.OK, result.Result) //return the id