using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using ComboBoxBasicCore.Models;

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

            return View();
        }

        public ActionResult GetCustomerLocationNameList(string text)
       {
            var items = new List<ItemModel>() {
                new ItemModel(){ Text = "AA"},
                new ItemModel(){ Text = "AB"},
                new ItemModel(){ Text = "AC"},
                new ItemModel(){ Text = "ACA"},
                new ItemModel(){ Text = "ACB"},
                new ItemModel(){ Text = "ACD"},
                new ItemModel(){ Text = "ABA"},
                new ItemModel(){ Text = "ABC"}
            };

            if (!string.IsNullOrEmpty(text))
            {
                items = items.Where(p => p.Text.ToLower().StartsWith(text.ToLower())).ToList();
            }

            return Json(items);
        }

    }
}
