-
Notifications
You must be signed in to change notification settings - Fork 17
Transitions
mauricioaniche edited this page Sep 14, 2010
·
5 revisions
You can add hypermedia to any of your resources. To do that you just have to implement the interface IBehaveAsResource. The most simple implementation would be the following:
public void SetRelations(Relations relations) { }
It actually returns no relations.
You might want to add a relation to some action. The following code does that:
public void SetRelations(Relations relations) { relations.Named("pay").Uses<SomeController>().SomeSimpleAction(); }
The code above creates a transition called “pay” and sets it to an action called “SomeSimpleAction”.
Your URL may have some parameters, just like an ID. You can pass it at the moment you are creating the transition. The following code does that:
public void SetRelations(Relations relations) { relations.Named("get").Uses<SomeController>().Get(this.Id); }
This code will actually get the Id and pass it to the Asp.NET MVC Url Generator. If its related route contains this parameter, it will include it in the Url.
You can point a transition to an external link.
public void SetRelations(Relations relations) { relations.Named("about").At("restfulie.caelumobjects.com"); }