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

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

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

		public ActionResult Categories()
		{
			List<Category> categories = new List<Category>();


			for (int i = 1; i < 5; i++)
			{
				Category currCategory = new Category
				{
					CategoryID = i,
					CategoryName = "Category " + i
				};

				categories.Add(currCategory);
			}

			return Json(categories, JsonRequestBehavior.AllowGet);
		}

		public void UpdateChild()
        {

        }
	}
}
