mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
If lambda takes an argument, it is dynamic, and is an uninitialized shape of the named type ShapeHelper and IShapeHelperFactory are obsolete - IShapeFactory itself is now dynamic --HG-- branch : dev
37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
using System.Web.Mvc;
|
|
using Orchard.ContentManagement;
|
|
using Orchard.DisplayManagement;
|
|
using Orchard.Themes;
|
|
|
|
namespace Orchard.Core.Contents.Controllers {
|
|
[Themed]
|
|
public class ItemController : Controller {
|
|
private readonly IContentManager _contentManager;
|
|
|
|
public ItemController(IContentManager contentManager, IShapeFactory shapeFactory) {
|
|
_contentManager = contentManager;
|
|
Shape = shapeFactory;
|
|
}
|
|
|
|
dynamic Shape { get; set; }
|
|
|
|
// /Contents/Item/Display/72
|
|
public ActionResult Display(int id) {
|
|
var contentItem = _contentManager.Get(id, VersionOptions.Published);
|
|
var model = _contentManager.BuildDisplay(contentItem);
|
|
return View(model);
|
|
}
|
|
|
|
// /Contents/Item/Preview/72
|
|
// /Contents/Item/Preview/72?version=5
|
|
public ActionResult Preview(int id, int? version) {
|
|
var versionOptions = VersionOptions.Latest;
|
|
if (version != null)
|
|
versionOptions = VersionOptions.Number((int)version);
|
|
|
|
var contentItem = _contentManager.Get(id, versionOptions);
|
|
var model = _contentManager.BuildDisplay(contentItem);
|
|
return View("Display", model);
|
|
}
|
|
}
|
|
} |