Data Access + WebAPI + MVC 4 Server Wrappers

5 posts, 0 answers
  1. Allan
    Allan avatar
    4 posts
    Member since:
    Feb 2014

    Posted 06 Mar 2014 Link to this post

    I'm attempting to create a new Kendo UI for ASP.NET MVC 4 project using the MVC Wrappers, Telerik Data Access for the data access layer, and WebAPI controllers, but not having much luck getting all three to work together.  It seems like it should be simple, but I'm not sure what I'm missing.

    From the Data Access documentation, I can find examples of using Data Access with MVC or Data Access with WebAPI.  From the Kendo side of things, I can find tutorials on WebAPI and MVC Wrappers, the Binding to a Web ApiController sample project, the Facts on Using Kendo UI With ASP.NET WebAPI blog, and even the UI for ASP.NET MVC sample application has a grid using WebAPI.  But none of these resources seem to use all three of the pieces I'm trying to fit together.  I've tried studying the examples that use two of the three parts and modifying them to work with the third, but nothing seems to work.

    Does anyone have a good, simple example of using a Data Access layer, with WebAPI, and MVC server wrappers or any pointers on how to modify the Binding to a Web ApiController project to use a Data Access layer instead?

    Thanks!
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 07 Mar 2014 Link to this post

    Hello Allan,

    Pleas find attached a sample project which uses Telerik Data, WebAPI and ASP.NET MVC 4. It is based on the original WebAPI binding code library project. 

    Regards,
    Atanas Korchev
    Telerik

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Allan
    Allan avatar
    4 posts
    Member since:
    Feb 2014

    Posted 07 Mar 2014 Link to this post

    Atanas, thanks for the fast reply!  I was able to replicate that with my own project and it worked like a charm.  
  5. Garry
    Garry avatar
    1 posts
    Member since:
    Nov 2013

    Posted 21 Mar 2014 Link to this post

    Atanas,
    Thank you for this sample, however I still have some conceptual questions please. It maybe that my knowledge isnt where it should be, but where I am having an issue is same setup as Alan, but I have three separate projects. I have a MVC 5 client app, an OpenAccess Web API service app, and an OpenAccess Model project.

    Obviously the OpenAccess Web API has to know about the model and all of that is working perfectly, but where I get lost is on the client side consuming the Web API. In my mind the the client should have no knowledge about the OpenAccess model class, but without a WSDL/Contract to describe the model I am not sure how the client is going to function without knowledge of it. I have poured through the examples dealing with your UI for ASP.NET MVC controls, but they all including this one have a direct reference to OpenAccess Model
     
    @(Html.Kendo().Grid<TelerikDataKendoGridWebApi.Product>()

    Should I actually reference the OpenAccess model project in the MVC client app? That seems to coupled to me, however your controls and your examples all lead me to believe it to be true.

    If I am incorrect do you mind providing another sample that shows how your controls can reference the Web API without sharing the OpenAccess project?

    Thanks you,
    Garry
  6. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 24 Mar 2014 Link to this post

    Hello Garry,

    The grid needs the type of the model in order to provide strongly-typed fluent interface. You can easily avoid referencing the OpenAccess project if you create another class which has the same properties as the OpenAccess model.

    Regards,
    Atanas Korchev
    Telerik
     

    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

     
Back to Top
UI for ASP.NET MVC is VS 2017 Ready