Using Parse together with Umbraco SurfaceController
Hi there, i have to get some data from a Parse database into a view in Umbraco. and i am havĂng some problems that i hope someone can help me with.
Firstly i am using a SurfaceController and i have an action called List that looks like this
public async Task<ActionResult> List()
{
var query = new ParseQuery<Property>().WhereNotEqualTo("ObjectId", string.Empty);
IEnumerable<Property> results = await query.FindAsync();
return PartialView("~/Views/Partials/List.cshtml", results);
}
i can see using debug mode in Visual Studio that i get the data i need, but when i try and call my PartialView like i am sending in my results i get this problem
The model item passed into the dictionary is of type 'System.Collections.ObjectModel.ReadOnlyCollection`1[Property]', but this dictionary requires a model item of type 'Property'.
Property is a Model
and my partialview for the moment just looks like this
I hope someone has the knowledge who can help me. Even if you dont understand the way i am doing it, if you know a way of using async in a surfaceController please tell me
Ok that was a mistake on my end, ofc i tried that many times, but i forgot to include it in this thread since i was messing around a lo with the view and the controller method
But if i do that, then i get this problem
The model item passed into the dictionary is of type 'System.Collections.ObjectModel.ReadOnlyCollection`1[vurdernu.Models.Property]', but this dictionary requires a model item of type 'vurdernu.Models.Property'.
And if i try and put System.Collections.ObjectModel.ReadOnlyCollection
I'm an async virgin, hard to get my head around it and problems like this. As far as I understand it you always have to have something await an async call and I doubt that views have a way of awaiting. If you think about it that makes sense, a view is rendering your html, it can't wait for your data to arrive whenever it wants (also defeats the purpose of async if you're going to synchronously wait for data to arrive before starting the render).
I could be way off, as I said I am very inexperienced in async!
public ActionResult List()
{
var query = new ParseQuery<Property>().WhereNotEqualTo("ObjectId", string.Empty);
var results = query.FindAsync();
return PartialView("~/Views/Partials/List.cshtml", results);
}
The model item passed into the dictionary is of type 'System.Threading.Tasks.UnwrapPromise`1[System.Collections.Generic.IEnumerable`1[vurdernu.Models.Property]]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[vurdernu.Models.Property]'.
Using Parse together with Umbraco SurfaceController
Hi there, i have to get some data from a Parse database into a view in Umbraco. and i am havĂng some problems that i hope someone can help me with.
Firstly i am using a SurfaceController and i have an action called List that looks like this
i can see using debug mode in Visual Studio that i get the data i need, but when i try and call my PartialView like i am sending in my results i get this problem
Property is a Model
and my partialview for the moment just looks like this
I hope someone has the answer to this since it really annoys me.
I hope someone has the knowledge who can help me. Even if you dont understand the way i am doing it, if you know a way of using async in a surfaceController please tell me
You're returning a
IEnumerable<Property>
but your view expects aProperty
.So the partial should probably be:
@inherits Umbraco.Web.Mvc.UmbracoViewPage<IEnumerable<Property>>
Ok that was a mistake on my end, ofc i tried that many times, but i forgot to include it in this thread since i was messing around a lo with the view and the controller method
But if i do that, then i get this problem
And if i try and put System.Collections.ObjectModel.ReadOnlyCollection
so it looks like this
then i get
Any ideas how i get passed this ?
Don't make it async :-)
I'm an async virgin, hard to get my head around it and problems like this. As far as I understand it you always have to have something
await
an async call and I doubt that views have a way of awaiting. If you think about it that makes sense, a view is rendering your html, it can't wait for your data to arrive whenever it wants (also defeats the purpose of async if you're going to synchronously wait for data to arrive before starting the render).I could be way off, as I said I am very inexperienced in async!
Ok so now my controller method looks like this
and my view now looks like this
and i get the error
is working on a reply...