using GridTestRemoteBinding.Models;
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
using Microsoft.Ajax.Utilities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Web;
using System.Web.Mvc;

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

            return View();
        }

        public ActionResult getMNotes([Kendo.Mvc.UI.DataSourceRequest] Kendo.Mvc.UI.DataSourceRequest request, string m_key)
        {
            //if (!string.IsNullOrEmpty(m_key))
            //{
                var sampleData = Enumerable.Range(0, 50).Select(i => new MModel
                {
                    OrderID = i,
                    Freight = i * 10,
                    OrderDate = DateTime.Now.AddDays(i),
                    ShipName = "ShipName " + i,
                    ShipCity = "ShipCity " + i
                });

                //System.Web.Script.Serialization.JavaScriptSerializer r = new System.Web.Script.Serialization.JavaScriptSerializer();
                var jsonObj = sampleData.ToList().ToDataSourceResult(request);
                return Json(jsonObj, JsonRequestBehavior.AllowGet);
            //}

            //return Json(new { Status = "Error", Message = "No M Passed" }, JsonRequestBehavior.AllowGet);
        }
    }
}
