Copied to clipboard

Flag this post as spam?

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


  • MB 273 posts 936 karma points
    Feb 02, 2021 @ 15:21
    MB
    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 252 posts 454 karma points MVP 4x 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 4124 posts 22215 karma points MVP 9x 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

  • MB 273 posts 936 karma points
    Apr 07, 2021 @ 09:20
    MB
    0

    Hi Matt,

    You are right, I don't have those files in the Vendr.DemoStore folder. If I download that entire folder, where should I place it?

    I can see your DEMO project's .SLN file refers to the two folders:

    • src\Vendr.DemoStore\Vendr.DemoStore.csproj
    • src\Vendr.DemoStore.Web\Vendr.DemoStore.Web.csproj

    Which mine doesn't. If I dowload the entire Vendr.DemoStore folder, how do I refer to it?

  • Bjarne Fyrstenborg 1280 posts 3990 karma points MVP 7x 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

Please Sign in or register to post replies

Write your reply to:

Draft