using Kendo.Mvc.UI;
using ServerSidePaging.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.Helpers;
using System.Web.Mvc;
using Kendo.Mvc.Extensions;

namespace ServerSidePaging.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";

            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your app description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }

        [HttpPost]
        public ActionResult GetData([DataSourceRequest] DataSourceRequest request)
        {
            var data = Enumerable.Range(1, 10).Select(i => new OrderResultModel
            {
                OrderId = i,                               
                ShipName = "ShipName " + i
            });

            return Json(data.ToDataSourceResult(request));
        }
    }
}
