using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using TelerikAspNetCoreApp17.Models;

namespace TelerikAspNetCoreApp17.Controllers
{
    public class GridController : Controller
    {
        public ActionResult Orders_Read([DataSourceRequest] DataSourceRequest request)
        {
            var result = Enumerable.Range(1, 10).Select(i => new OrderViewModel
            {
                OrderID = i,
                Freight = i * 10,
                OrderDate = new DateTime(2016, 9, 15).AddDays(i % 7),
                ShipName = "ShipName " + i,
                ShipCity = "ShipCity " + i
            });

            var dsResult = result.ToDataSourceResult(request);
            return Json(dsResult);
        }

        public JsonResult GetShipNames()
        {
            List<string> shipNames = new List<string>();

            for (int i = 1; i < 11; i++)
            {
                string shipName = "ShipName " + i;

                shipNames.Add(shipName);
            }

            return Json(shipNames);
        }

        public void Orders_Update()
        {

        }

        public void Orders_Destroy()
        {

        }
    }
}
