using Kendo.Mvc.UI;
using Kendo.Mvc.Extensions;
using KendoGridAjaxBinding.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace KendoGridAjaxBinding.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewBag.Message = "Welcome to ASP.NET MVC!";

            return View();
        }

        public ActionResult Products_Read([DataSourceRequest]DataSourceRequest request)
        {
            using (var northwind = new NorthwindEntities())
            {
                IQueryable<Product> products = northwind.Products;
                DataSourceResult result = products.ToDataSourceResult(request, p => new ProductViewModel {  ProductID = p.ProductID, ProductName = p.ProductName, CustomDate = DateTime.Now });
                return Json(result);
            }
        }

        public ActionResult Products_Update([DataSourceRequest]DataSourceRequest request, Product product, [Bind(Prefix = "products")]IEnumerable<Product> products)
        {
            return Json("");
        }
    }
}
