Source of GetProducts Action on Home Controller

5 posts, 0 answers
  1. Bret
    Bret avatar
    1 posts
    Member since:
    Nov 2016

    Posted 16 Dec 2016 Link to this post

    On the demo page for Server filtering in ASP.NET Core AutoComplete the DataSource property is setup to read products using the GetProducts action of the Home controller:

    read.Action("GetProducts", "Home");

     

    Anyway you could publish the contents of the GetProducts action?

  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    1268 posts

    Posted 21 Dec 2016 Link to this post

    Hello Bret,

    Here's the content of the GetProducts action:
    public JsonResult GetProducts(string text)
            {
                using (var northwind = GetContext())
                {
                    var products = northwind.Products.Select(product => new ProductViewModel
                    {
                        ProductID = product.ProductID,
                        ProductName = product.ProductName,
                        UnitPrice = product.UnitPrice.Value,
                        UnitsInStock = product.UnitsInStock.Value,
                        UnitsOnOrder = product.UnitsOnOrder.Value,
                        Discontinued = product.Discontinued
                    });
     
                    if (!string.IsNullOrEmpty(text))
                    {
                        products = products.Where(p => p.ProductName.Contains(text));
                    }
     
                    return Json(products.ToList());
                }
            }

    The demos can be run locally through our Sample Application. It allows you to review in more detail their implementation and modify/test them. Instructions on running the sample application are available in this documentation article.

    Regards,
    Ivan Danchev
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Marc
    Marc avatar
    2 posts
    Member since:
    Jan 2017

    Posted 16 May in reply to Ivan Danchev Link to this post

    This is good to know, but there are two issues: first, these code-gaps on the demo-site are *everywhere*, ever since it was redone (when the old, default ASPX examples were dumped).  This is glaring hole. It makes the demo site almost useless, because key pieces of code, without which the example will not function, are missing.  Further, there is no pointer on the demo site that even addresses this lacuna, or points to the Sample Application.

     

    Second issue: the sample application is out of date.  It hasn't been updated since July 2016, it hasn't been renamed from "MVC 6" to "Core", the instructions require VS 2015, etc.  I'll clone it so that I can look at the code, but will it really be usable as an example project that I can "play" with?  There have been a lot of changes in project structure since then.

  4. Marc
    Marc avatar
    2 posts
    Member since:
    Jan 2017

    Posted 16 May in reply to Marc Link to this post

    My bad--I just saw the "deprecation notice" on the github repo.

    > The repository has been deprecated in favor of our official distribution packages.

    However, the documentation itself still points to it, still refers to VS 2015, etc.

  5. Ivan Danchev
    Admin
    Ivan Danchev avatar
    1268 posts

    Posted 18 May Link to this post

    Hello Marc,

    Thank you for the feedback. We will make sure to update the documentation as soon as possible so that it properly reflects the supported Core version.

    Regards,
    Ivan Danchev
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top