Making sure the global widget admin page is still usable when no layers are defined.

work item: 17538

--HG--
branch : 1.x
This commit is contained in:
Nathan Heskew
2011-03-28 10:27:35 -07:00
parent adbd9da232
commit b369eaa11b

View File

@@ -54,12 +54,11 @@ namespace Orchard.Widgets.Controllers {
IEnumerable<LayerPart> layers = _widgetsService.GetLayers();
if (layers.Count() == 0) {
Services.Notifier.Error(T("Layer not found: {0}", layerId));
return RedirectToAction("Index");
Services.Notifier.Error(T("There are no widget layers defined. A layer will need to be added in order to add widgets to any part of the site."));
}
LayerPart currentLayer = layerId == null
? layers.First()
? layers.FirstOrDefault()
: layers.FirstOrDefault(layer => layer.Id == layerId);
if (currentLayer == null && layerId != null) { // Incorrect layer id passed