using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace KendoUIMvcApplication5.Controllers
{
    using Kendo.Mvc.Extensions;
    using Kendo.Mvc.UI;

    using KendoUIMvcApplication5.Models;

    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewBag.Message = "Welcome to ASP.NET MVC!";

            return View();
        }

        public ActionResult About()
        {
            ViewBag.Units = UnitModel.GetModels();
            ViewBag.Message = "Your app description page.";

            return View();
        }

        public ActionResult Read([DataSourceRequest] DataSourceRequest request)
        {
            return Json(UnitModel.GetModels().ToDataSourceResult(request));
        }

        [HttpPost]
        public ActionResult Update([DataSourceRequest] DataSourceRequest request, UnitModel model)
        {
            return Json(new[] { model }.ToDataSourceResult(request, ModelState));
        }

        public ActionResult Submit(UnitModel model)
        {
            if (model != null)
            {
                ViewBag.Items = model.PostedIDs;
            }
            return RedirectToAction("Index");
        }

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

            return View();
        }
    }
}
