This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace Tri.Example.Products | |
{ | |
public interface IProductDataProvider | |
{ | |
Product FetchProductData(Product model); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Web.Mvc; | |
namespace Tri.Example.Products | |
{ | |
public class ProductsAreaRegistration : AreaRegistration | |
{ | |
public override string AreaName | |
{ | |
get | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//JSON data route | |
routes.MapRoute( | |
"JSON", | |
"json/{*pageUrl}", | |
new { controller = "Data", action = "Json" } | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//JSON data route (when DataController is the area "Data") | |
routes.MapRoute( | |
"JSON", | |
"json/{*pageUrl}", | |
new { controller = "Data", action = "Json" } | |
).DataTokens.Add("area", "Data"); |