#17682: Content can not change from "Add to a list" to "None"

--HG--
branch : 1.x
This commit is contained in:
Dave Reed
2011-04-07 12:31:23 -07:00
parent 5fa7535eb4
commit a4e6f8e549

View File

@@ -4,6 +4,7 @@ using System.Web.Mvc;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.ContentManagement.Drivers;
using Orchard.Core.Common.Models;
using Orchard.Core.Containers.Models;
using Orchard.Core.Containers.ViewModels;
using Orchard.Localization;
@@ -27,7 +28,7 @@ namespace Orchard.Core.Containers.Drivers {
return ContentShape(
"Parts_Containable_Edit",
() => {
var commonPart = part.As<ICommonPart>();
var commonPart = part.As<CommonPart>();
var model = new ContainableViewModel();
if (commonPart != null && commonPart.Container != null) {
@@ -37,10 +38,12 @@ namespace Orchard.Core.Containers.Drivers {
if (updater != null) {
var oldContainerId = model.ContainerId;
updater.TryUpdateModel(model, "Containable", null, null);
if (oldContainerId != model.ContainerId)
if (oldContainerId != model.ContainerId) {
if (commonPart != null) {
commonPart.Container = _contentManager.Get(model.ContainerId, VersionOptions.Latest);
var containerItem = _contentManager.Get(model.ContainerId, VersionOptions.Latest);
commonPart.Record.Container = containerItem == null ? null : containerItem.Record;
}
}
}
// note: string.isnullorempty not being recognized by linq-to-nhibernate hence the inline or