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

namespace GridSortGroup.Controllers
{
	public partial class GridController : Controller
    {
		public ActionResult Orders_Read([DataSourceRequest]DataSourceRequest request)
		{
			var result = new List<OrderViewModel>();
			for (int i = 0; i < 50; i++)
			{
				result.Add(new OrderViewModel
				{
					OrderID = i,
					Freight = i * 10,
					OrderDate = DateTime.Now.AddDays(i),
					ShipName = "ShipName " + i,
					ShipCity = "ShipCity " + i
				});
			}

			for (int i = 0; i < 50; i++)
			{
				result.Add(new OrderViewModel
				{
					OrderID = i + 50,
					Freight = i * 10,
					OrderDate = DateTime.Now.AddDays(i),
					ShipName = "ShipName " + i + 10,
					ShipCity = "ShipCity " + i + 10
				});
			}


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