Files
Umbraco-CMS/src/Umbraco.Web/Mvc/SurfaceController.cs
Shannon Deminick c0b5525dd7 Removed 'Boot' method from WebBootManager as it was never supposed to be there in the first place.
Removed test code from 'SurfaceController'.
Added comments to IApplicationEventHandler.
2013-01-18 02:31:51 +03:00

89 lines
2.4 KiB
C#

using System;
using System.Collections.Concurrent;
using System.Web.Mvc;
using Umbraco.Core.Models;
using Umbraco.Core;
namespace Umbraco.Web.Mvc
{
/// <summary>
/// The base controller that all Presentation Add-in controllers should inherit from
/// </summary>
[MergeModelStateToChildAction]
public abstract class SurfaceController : PluginController
{
/// <summary>
/// Default constructor
/// </summary>
/// <param name="umbracoContext"></param>
protected SurfaceController(UmbracoContext umbracoContext)
: base(umbracoContext)
{
}
/// <summary>
/// Empty constructor, uses Singleton to resolve the UmbracoContext
/// </summary>
protected SurfaceController()
: base(UmbracoContext.Current)
{
}
/// <summary>
/// Redirects to the Umbraco page with the given id
/// </summary>
/// <param name="pageId"></param>
/// <returns></returns>
protected RedirectToUmbracoPageResult RedirectToUmbracoPage(int pageId)
{
return new RedirectToUmbracoPageResult(pageId, UmbracoContext);
}
/// <summary>
/// Redirects to the Umbraco page with the given id
/// </summary>
/// <param name="publishedContent"></param>
/// <returns></returns>
protected RedirectToUmbracoPageResult RedirectToUmbracoPage(IPublishedContent publishedContent)
{
return new RedirectToUmbracoPageResult(publishedContent, UmbracoContext);
}
/// <summary>
/// Redirects to the currently rendered Umbraco page
/// </summary>
/// <returns></returns>
protected RedirectToUmbracoPageResult RedirectToCurrentUmbracoPage()
{
return new RedirectToUmbracoPageResult(CurrentPage, UmbracoContext);
}
/// <summary>
/// Returns the currently rendered Umbraco page
/// </summary>
/// <returns></returns>
protected UmbracoPageResult CurrentUmbracoPage()
{
return new UmbracoPageResult();
}
/// <summary>
/// Gets the current page.
/// </summary>
protected IPublishedContent CurrentPage
{
get
{
if (!ControllerContext.RouteData.DataTokens.ContainsKey("umbraco-route-def"))
throw new InvalidOperationException("Can only use " + typeof(UmbracoPageResult).Name + " in the context of an Http POST when using the BeginUmbracoForm helper");
var routeDef = (RouteDefinition)ControllerContext.RouteData.DataTokens["umbraco-route-def"];
return routeDef.PublishedContentRequest.PublishedContent;
}
}
}
}