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

namespace MVC_Grid.Controllers
{
	public partial class ListViewController : Controller
    {
		public List<OrderViewModel> GetAll()
		{
            var result = Enumerable.Range(1, 50).Select(i => new OrderViewModel
            {
                OrderID = i,
                Freight = i * 10,
                OrderDate = DateTime.Now.AddDays(i),
                ShipName = "ShipName " + i,
                ShipCity = "ShipCity " + i
            }).ToList();
            return result;
		}
		public ActionResult Orders_Read([DataSourceRequest]DataSourceRequest request)
		{

            var result = GetAll();
			return Json(result.ToDataSourceResult(request));
		}
        public ActionResult GetCard(int id)
        {
            var model = GetAll().Where(item => item.OrderID == id).First();
            return PartialView("_Card",model);
        }
	}
}
