AjaxList Client Side API





    Awesome/AjaxList/MealsApiDemoAjaxListController.cs
    using AweCoreDemo.Data;
    using Microsoft.AspNetCore.Mvc;
    using Omu.AwesomeMvc;


    namespace AweCoreDemo.Controllers.Awesome.AjaxList
    {
    public class MealsApiDemoAjaxListController : Controller
    {
    public IActionResult Search(int page, int pageSize = 5, string meal = "")
    {
    var query = Db.Meals.Where(o => o.Name.Contains(meal)).AsQueryable();

    var count = query.Count();
    var items = AweUtil.GetPage(query, page, pageSize).ToList();

    return Json(new AjaxListResult
    {
    Items = items.Select(o => new KeyContent(o.Id, o.Name)),
    More = count > page * pageSize // bool - show More button or not
    });
    }
    }
    }



    Comments