Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • MBE 244 posts 845 karma points
    Feb 02, 2021 @ 15:21
    MBE
    0

    Modelbuilder and namespace

    Hi (Matt), ;)

    I've been digging around the demo store and noticed that you use code that doesn't exactly work on my machine so I'm wondering what I'm missing. I have a feeling it might be related to which modelbuilder is used?

    Eg.:

    On the home page you use: @Html.Action("FeaturedProducts", "ProductSurface") which returns the following error:

    No route in the route table matches the supplied values.
    

    You also seem to use the following on the search page where you use the namespace @using Vendr.DemoStore;

    @using Vendr.DemoStore; 
    @Html.Partial("Pagination",  Model.Cast<IPublishedContent, object>())
    

    Which returns:

    CS1061: 'PagedResult<IPublishedContent>' does not contain a definition for 'Cast' and no accessible extension method 'Cast' accepting a first argument of type 'PagedResult<IPublishedContent>' could be found (are you missing a using directive or an assembly reference?)
    

    Since I don't use the Vendr.DemoStore I'm wondering if it's possible to see what's inside that namespace?

    // Mike

  • Tom Madden 241 posts 396 karma points MVP c-trib
    Feb 02, 2021 @ 16:32
    Tom Madden
    0

    Hi Mike, the demo store is open source on Github,

    https://github.com/vendrhub/vendr-demo-store

    HTH

    t

  • Matt Brailsford 2958 posts 15629 karma points MVP 7x c-trib
    Feb 03, 2021 @ 09:22
    Matt Brailsford
    0

    Hi Mike,

    I don't think this is a ModelsBuilder issue, I just think you have missed copying some bits over.

    The first code snippet is attempting to render a child action, but given the error, it would appear you haven't copied over our ProductSurfaceController which is responsible for rendering the featured products

    https://github.com/vendrhub/vendr-demo-store/blob/main/src/Vendr.DemoStore/Web/Controllers/ProductSurfaceController.cs#L25

    Regarding the second issue, again, it looks like you've not copied over the Cast extension method which you can find here

    https://github.com/vendrhub/vendr-demo-store/blob/main/src/Vendr.DemoStore/Extensions/PagedResultExtensions.cs#L8

    Hope this helps

    Matt

    PS As Tom said, the whole of the demo store is open source so you can review all the code for it at https://github.com/vendrhub/vendr-demo-store

  • Bjarne Fyrstenborg 1182 posts 3441 karma points MVP 4x c-trib
    Feb 03, 2021 @ 10:39
    Bjarne Fyrstenborg
    0

    Hi Mike

    When using ModelsBuilder you should be aware of these settings in Web.config: https://github.com/vendrhub/vendr-demo-store/blob/main/src/Vendr.DemoStore.Web/Web.config#L50-L54

    With these settings in demo store, ModelsBuilder generates the classes in this folder and use the namespace Vendr.DemoStore.Models: https://github.com/vendrhub/vendr-demo-store/tree/main/src/Vendr.DemoStore/Models

    With this approach also ensure that new generated models are included in the project and compiled in the assembly, when building the project/solution.

    /Bjarne

  • 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.

Please Sign in or register to post replies