Skip to content

Instantly share code, notes, and snippets.

public virtual ActionResult ExampleAction(object entity, int containerSize = 0)
{
ModelType = ModelType.Entity;
var viewData = GetViewData(entity);
SetupViewData(containerSize, viewData);
var model = ProcessModel(entity, GetViewType(viewData)) ?? entity;
return View(viewData.ViewName, model);
}
public virtual ActionResult ExampleActionWithParameter(object entity, string myCustomParam, int containerSize = 0)
@model Tri.Example.Products.Product
<div @Markup.Entity(Model)>
<h1 @Markup.Property(Model,"Title")>@Model.Title</h1>
<p @Markup.Property(Model,"Description")>@Model.Description</p>
<p>
Only @Model.Stock items left in stock.
<a href="buy?id=@Model.ProductId">Buy now</a> for just $@Model.Price!
</p>
</div>
using Sdl.Web.Common.Interfaces;
using System;
namespace Tri.Example.Products
{
public class ProductsController : Sdl.Web.Mvc.Controllers.BaseController
{
public IProductDataProvider ProductDataProvider { get; set; }
public ProductsController(IContentProvider contentProvider, IRenderer renderer, IProductDataProvider productDataProvider)
{
<?xml version="1.0"?>
<unity>
<!-- other assemblies and namespaces -->
<assembly name="Tri.Example.Products" />
<namespace name="Tri.Example.Products" />
<containers>
<container name="main">
<types>
<!-- other types -->
<type type="IProductDataProvider" mapTo="MyProductDataProvider"/>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Tri.Example.Products
{
public interface IProductDataProvider
{
Product FetchProductData(Product model);
using Sdl.Web.Common.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Tri.Example.Products
{
public class Product : EntityBase
{
using System.Web.Mvc;
namespace Tri.Example.Products
{
public class ProductsAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
@willprice76
willprice76 / SimpleJsonDataController.cs
Last active August 29, 2015 14:07
Simpler Example TRI Data Controller
using Sdl.Web.Common.Interfaces;
using Sdl.Web.Mvc.Controllers;
using Sdl.Web.Common.Models;
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Reflection;
@willprice76
willprice76 / TriJsonDataRoute.cs
Last active August 29, 2015 14:07
Tridion Reference Implementation JSON Data Controller example route
//JSON data route
routes.MapRoute(
"JSON",
"json/{*pageUrl}",
new { controller = "Data", action = "Json" }
);
@willprice76
willprice76 / TriJsonDataRouteWithArea.cs
Last active August 29, 2015 14:07
Tridion Reference Implementation JSON Data Controller example route (with Area)
//JSON data route (when DataController is the area "Data")
routes.MapRoute(
"JSON",
"json/{*pageUrl}",
new { controller = "Data", action = "Json" }
).DataTokens.Add("area", "Data");