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

namespace DropDownListValues.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
           var model = new SimpleModel()
           {
               Fields = new List<Field>()
               {
                      new Field
                      {
                          Text = "asdad",
                          Value = "1",
                          
                      },
           
                      new Field
                      {
                          Text = "qweqwqw",
                          Value = "2"
                      }
           
               }
           };

            return View(model);
        }

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

            return View();
        }

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

            return View();
        }
        public ActionResult TypeAhead([DataSourceRequest] DataSourceRequest request, int field)
        {
            var values = new List<Field>();
            if(field == 0)
            {
                values.Add(new Field{ Text = "One", Value = "1"  });
                values.Add(new Field{ Text = "Three", Value = "3" });
                values.Add(new Field{ Text = "Five", Value = "5" });
                values.Add(new Field{ Text = "Seven", Value = "7" });
                values.Add(new Field{ Text = "Nine", Value = "9" });

            }
            else if (field == 1)
            {
                values.Add(new Field { Text = "Two", Value = "2" });
                values.Add(new Field { Text = "Four", Value = "4" });
                values.Add(new Field { Text = "Six", Value = "6" });
                values.Add(new Field { Text = "Eight", Value = "8" });

            }
            return Json(values, JsonRequestBehavior.AllowGet);

        }
    }
}
