--HG--
branch : dev
This commit is contained in:
Andre Rodrigues 2010-10-14 16:25:14 -07:00
commit af3a348770
2 changed files with 19 additions and 2 deletions

View File

@ -44,6 +44,12 @@ namespace Orchard.Widgets.Controllers {
layers.First() :
layers.FirstOrDefault(layer => layer.Id == id);
if (currentLayer == null) {
// Incorrect layer id passed
Services.Notifier.Error(T("Layer not found: {1}", id));
return RedirectToAction("Index");
}
currentLayerWidgets = _widgetsService.GetWidgets().Where(widgetPart => widgetPart.LayerPart.Id == currentLayer.Id);
}
else {
@ -237,7 +243,7 @@ namespace Orchard.Widgets.Controllers {
Services.Notifier.Error(T("Removing Layer failed: {0}", exception.Message));
}
return RedirectToAction("Index", "Admin", new { id });
return RedirectToAction("Index");
}
public ActionResult EditWidget(int id) {

View File

@ -3,6 +3,7 @@ using System.Linq;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.Core.Common.Models;
using Orchard.Themes;
using Orchard.Widgets.Models;
@ -78,11 +79,21 @@ namespace Orchard.Widgets.Services {
}
public void DeleteLayer(int layerId) {
// Delete widgets in the layer
foreach (WidgetPart widgetPart in GetWidgets(layerId)) {
DeleteWidget(widgetPart.Id);
}
// Delete actual layer
_contentManager.Remove(GetLayer(layerId).ContentItem);
}
public WidgetPart GetWidget(int widgetId) {
return GetWidgets().FirstOrDefault(widgetPart => widgetPart.Id == widgetId);
return _contentManager
.Query<WidgetPart, WidgetPartRecord>()
.Where(widget => widget.Id == widgetId)
.List()
.FirstOrDefault();
}
public WidgetPart CreateWidget(int layerId, string widgetType, string title, string position, string zone) {