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

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

            return View();
        }

        public ActionResult HttpAttrRequired()
        {
            return View();
        }

		public ActionResult Sorted()
        {
            return View();
        }

        public ActionResult HeaderTemplate()
        {
            return View();
        }

        public JsonResult _SortedData()
        {
            var list = new List<UtilityTypeModel>
            {
                new UtilityTypeModel() {
                    UtilityTypeID = 1,
                    Code = "ABC",
                    Description = "ABC",
                    SortOrder = 2
                },
                new UtilityTypeModel() {
                    UtilityTypeID = 2,
                    Code = "BVC",
                    Description = "BVC",
                    SortOrder = 1
                },
                new UtilityTypeModel() {
                    UtilityTypeID = 3,
                    Code = "CDA",
                    Description = "CDA",
                    SortOrder = 4
                },
                new UtilityTypeModel() {
                    UtilityTypeID = 4,
                    Code = "ADD",
                    Description = "ADD",
                    SortOrder = 3
                }
            };

            return Json(list.OrderBy(u => u.SortOrder), JsonRequestBehavior.AllowGet);
        }
    }
}
