using Core_DropDownList.Models;
using Kendo.Mvc.Extensions;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;


namespace Core_DropDownList.Controllers
{
    public class DropDownController : Controller
    {
        public ActionResult Component_DropDown([Kendo.Mvc.UI.DataSourceRequest] Kendo.Mvc.UI.DataSourceRequest request,int? ProductiveUnitDropDown)
        {
            var components = new List<ColorsModel>() { 
                new ColorsModel() {
                    id = 1
                },
                new ColorsModel() {
                    id = 2
                },
                new ColorsModel() {
                    id = 3
                }

            };
            
            if (ProductiveUnitDropDown != null)
            {
                var temp = components.Find(item => item.id == ProductiveUnitDropDown);
                components.Clear();
                components.Add(temp);
            }
            return Json(components.ToDataSourceResult(request));
        }
    }
}
