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

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

            return View();
        }

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

            return View();
        }

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

            return View();
        }

        public JsonResult GetFilterUser(string text)
        {
            var data = Enumerable.Range(1, 20).Select(i => new TestModel
            {
                 UserID = i,
                 FullUserInfo = "Organization " + i

            });

            if (!string.IsNullOrEmpty(text))
            {
                data = data.Where(p => p.FullUserInfo.Contains(text));
            }

            return Json(data, JsonRequestBehavior.AllowGet);
        }
    }
}
