From f11dc7f3cd9140ad155f8c9449853404ca8b36d7 Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Wed, 21 Nov 2012 17:38:54 -0100 Subject: [PATCH] Correcting a few methods in the DataTypeService. Adding publish = false in save methods, to ensure that Published isn't set to true. --- .../Models/IDataTypeDefinition.cs | 3 +-- src/Umbraco.Core/Services/ContentService.cs | 6 +++--- src/Umbraco.Core/Services/DataTypeService.cs | 21 ++++++++++++++++--- src/Umbraco.Core/Services/IDataTypeService.cs | 11 ++++++++-- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/Umbraco.Core/Models/IDataTypeDefinition.cs b/src/Umbraco.Core/Models/IDataTypeDefinition.cs index 582bf6919d..e04820940a 100644 --- a/src/Umbraco.Core/Models/IDataTypeDefinition.cs +++ b/src/Umbraco.Core/Models/IDataTypeDefinition.cs @@ -36,8 +36,7 @@ namespace Umbraco.Core.Models /// Gets or sets the path /// [DataMember] - string Path //Setting this value should be handled by the class not the user - { get; set; } + string Path { get; set; } /// /// Id of the user who created this entity diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs index b95c29c368..428c166374 100644 --- a/src/Umbraco.Core/Services/ContentService.cs +++ b/src/Umbraco.Core/Services/ContentService.cs @@ -470,7 +470,7 @@ namespace Umbraco.Core.Services var repository = RepositoryResolver.ResolveByType(_unitOfWork); SetWriter(content, userId); - + content.ChangePublishedState(false); repository.AddOrUpdate(content); _unitOfWork.Commit(); @@ -503,9 +503,8 @@ namespace Umbraco.Core.Services { foreach (var content in contents) { - - SetWriter(content, userId); + content.ChangePublishedState(false); repository.AddOrUpdate(content); _unitOfWork.Commit(); } @@ -550,6 +549,7 @@ namespace Umbraco.Core.Services foreach (var content in contents) { SetWriter(content.Value, userId); + content.Value.ChangePublishedState(false); repository.AddOrUpdate(content.Value); _unitOfWork.Commit(); } diff --git a/src/Umbraco.Core/Services/DataTypeService.cs b/src/Umbraco.Core/Services/DataTypeService.cs index c5aa8951d9..6ab55ab9cc 100644 --- a/src/Umbraco.Core/Services/DataTypeService.cs +++ b/src/Umbraco.Core/Services/DataTypeService.cs @@ -37,19 +37,34 @@ namespace Umbraco.Core.Services return repository.Get(id); } + /// + /// Gets a by its unique guid Id + /// + /// Unique guid Id of the DataType + /// + public IDataTypeDefinition GetDataTypeDefinitionById(Guid id) + { + var repository = RepositoryResolver.ResolveByType(_unitOfWork); + + var query = Query.Builder.Where(x => x.Key == id); + var definitions = repository.GetByQuery(query); + + return definitions.FirstOrDefault(); + } + /// /// Gets a by its control Id /// /// Id of the DataType control - /// - public IDataTypeDefinition GetDataTypeDefinitionById(Guid id) + /// Collection of objects with a matching contorl id + public IEnumerable GetDataTypeDefinitionByControlId(Guid id) { var repository = RepositoryResolver.ResolveByType(_unitOfWork); var query = Query.Builder.Where(x => x.ControlId == id); var definitions = repository.GetByQuery(query); - return definitions.FirstOrDefault(); + return definitions; } /// diff --git a/src/Umbraco.Core/Services/IDataTypeService.cs b/src/Umbraco.Core/Services/IDataTypeService.cs index 9ad1d85a1d..8b5fa73d15 100644 --- a/src/Umbraco.Core/Services/IDataTypeService.cs +++ b/src/Umbraco.Core/Services/IDataTypeService.cs @@ -18,9 +18,9 @@ namespace Umbraco.Core.Services IDataTypeDefinition GetDataTypeDefinitionById(int id); /// - /// Gets a by its control Id + /// Gets a by its unique guid Id /// - /// Id of the DataType control + /// Unique guid Id of the DataType /// IDataTypeDefinition GetDataTypeDefinitionById(Guid id); @@ -61,5 +61,12 @@ namespace Umbraco.Core.Services /// /// An enumerable list of objects IEnumerable GetAllDataTypes(); + + /// + /// Gets a by its control Id + /// + /// Id of the DataType control + /// + IEnumerable GetDataTypeDefinitionByControlId(Guid id); } } \ No newline at end of file