I have this issue that I have been stuck on for a few days now.
Here is my scenario: I have data stored in custom table and I need to get that data and display in a view.
I had hijacked the HTTP request so that I could pass some parameter, and I got an error that the I am passing my custom Model, but a a model of type "RenderModel" is expected. I changed my custom Model to inherit from the class "RenderModel"
Here is my code:
Controller:
public class AccommodationController : SurfaceController
{
[System.Web.Http.HttpGet]
public ActionResult Index(int accommodationId)
{
var content = Umbraco.TypedContent(Config.HomeNode);
return new GetAccomodationById<ActionResult>(content)
{
OnComplete = (model) => View("Accommodation", model),
OnFailed = () => View("Error")
}.Execute(accommodationId);
}
}
Please note this line:
var content = Umbraco.TypedContent(Config.HomeNode);
I had just added that line so that I have "Umbraco" page that I can use when I initialize my Model.
And here is my Model:
public class SingleAccommodationViewModel : RenderModel
{
public SingleAccommodationViewModel(IPublishedContent content) : base(content) {}
public int AccomodationId { get; set; }
public string Name { get; set; } }
Please note this line on my controller :
var content = Umbraco.TypedContent(Config.HomeNode);
I am implicitly getting the home page to pass to my Model constructor, because this in not an Umbraco Page, and for that reason it wont be found on the Umbraco Context. So I am passing the homepage so that I dont pass a null "iPublishedContent" object to my model. However I get a "Object reference not set to an instance of an object." error.
Please help.
Render view with data stored in Custom Tables
Hi guys,
I have this issue that I have been stuck on for a few days now. Here is my scenario: I have data stored in custom table and I need to get that data and display in a view. I had hijacked the HTTP request so that I could pass some parameter, and I got an error that the I am passing my custom Model, but a a model of type "RenderModel" is expected. I changed my custom Model to inherit from the class "RenderModel"
Here is my code:
Controller:
Please note this line:
I had just added that line so that I have "Umbraco" page that I can use when I initialize my Model.
And here is my Model:
Please note this line on my controller :
I am implicitly getting the home page to pass to my Model constructor, because this in not an Umbraco Page, and for that reason it wont be found on the Umbraco Context. So I am passing the homepage so that I dont pass a null "iPublishedContent" object to my model. However I get a "Object reference not set to an instance of an object." error. Please help.
Anyone with any sort of help on this issue ?
is working on a reply...