using AutoComplteDemo.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
 
namespace Mvc_JqueryAutoComplete.Controllers
{
    public class HomeController : Controller
    {
       
        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public JsonResult GetCountries(string Prefix)
        {
            List<CityModel> ObjList = new List<CityModel>()
            {

                new CityModel {Id=1,Name="Latur" },
                new CityModel {Id=2,Name="Mumbai" },
                new CityModel {Id=3,Name="Pune" },
                new CityModel {Id=4,Name="Delhi" },
                new CityModel {Id=5,Name="Dehradun" },
                new CityModel {Id=6,Name="Noida" },
                new CityModel {Id=7,Name="New Delhi" }

        };

            var Countries = (from c in ObjList
                             where c.Name.StartsWith(Prefix)
                             select new { c.Name, c.Id });
            return Json(Countries, JsonRequestBehavior.AllowGet);
        }
    }
}
