Our company supports the Real Estate industry and I an trying to create a page in Umbraco that load the details of the listing from an id passed in the url. I have tried several examples so far and am lost as to what the missing piece is. The data is retrieved from an external MLS database via a REST API.
For my Controller, I have tried RenderMvcController, SurfaceController, and PluginController. It currently looks like this:
public class PropertyController : Umbraco.Web.Mvc.PluginController
{
public PropertyController()
: this(UmbracoContext.Current)
{
}
public PropertyController(UmbracoContext umbracoContext)
: base(umbracoContext)
{
}
public ActionResult Index(string propertyID)
{
dbzBest.Models.PropertyDetails p = new dbzBest.Models.PropertyDetails();
umbraco.NodeFactory.Node node = umbraco.uQuery.GetNodesByName("real-estate").FirstOrDefault();
IPublishedContent currentNode = Umbraco.Content(node.Id);
p = zbdLibrary.GlobalFunctions.zbdAPI("property/GetDetails/" + propertyID).jsonToEntity<dbzBest.Models.PropertyDetails>();
//***Using this line returns page as expected, but no info on the property. I get null errors with out it.
//return View("real-estate", CreateRenderModel(currentNode));
//this line fails. How do I pass this data to the view?
return View("real-estate", p);
}
private RenderModel CreateRenderModel(IPublishedContent content)
{
var model = new RenderModel(content, CultureInfo.CurrentUICulture);
//add an umbraco data token so the umbraco view engine executes
RouteData.DataTokens["umbraco"] = model;
return model;
}
}
How to pass data to view from an external source
Our company supports the Real Estate industry and I an trying to create a page in Umbraco that load the details of the listing from an id passed in the url. I have tried several examples so far and am lost as to what the missing piece is. The data is retrieved from an external MLS database via a REST API.
I have a custom route that looks like this:
For my Controller, I have tried RenderMvcController, SurfaceController, and PluginController. It currently looks like this:
Can someone please tell me what I am missing?
Thanks
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.