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

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

            return View();
        }

        public ActionResult GetChildValues(string parentValue)
        {
            if (parentValue == "FirstParent")
            {
                List<string> childValues = new List<string>() { "child1", "child11", "child111" };
                return Json(new
                {
                    list = childValues
                }, JsonRequestBehavior.AllowGet);
            }
            else if (parentValue == "SecondParent")
            {
                List<string> childValues = new List<string>() { "child2", "child22", "child222" };
                return Json(new
                {
                    list = childValues
                }, JsonRequestBehavior.AllowGet);
            }
            else
            {
                List<string> childValues = new List<string>() { "child1", "child11", "child111", "child2", "child22", "child222"};
                return Json(new
                {
                    list = childValues
                }, JsonRequestBehavior.AllowGet);
            }
        }
    }
}
