using System.Collections;
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 class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewBag.Message = "Welcome to ASP.NET MVC!";            

            return View(GetData());
        }

        IEnumerable GetData()
        {
            return Enumerable.Range(1, 10).Select(i => new HoursModel {
                Id = i,
                List = GetHours()
            });
        }

        double[] GetHours()
        {
            return Enumerable.Range(1, 54).Select(i => (double)i).ToArray();
        }

        public ActionResult Update([DataSourceRequest] DataSourceRequest request, IEnumerable<HoursModel> models)
        {
            //TODO: do something with the model
            return Json(models.ToDataSourceResult(request));
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
    }
}
