using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using System.Threading.Tasks;
using GridAndMenuCoreApp.Models;
using Microsoft.AspNetCore.Mvc;

namespace GridAndMenuCoreApp.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {
            return View();
        }

        public IActionResult About()
        {
            ViewData["Message"] = "Your application description page.";

            return View();
        }

        public IActionResult Contact()
        {
            ViewData["Message"] = "Your contact page.";

            return View();
        }

        public IActionResult Error()
        {
            return View();
        }

        public JsonResult GetOccupations(string text)
        {
            List<CaseOccupationViewModel> occupations = new List<CaseOccupationViewModel>();

            for (int i = 0; i < 10; i++)
            {
                CaseOccupationViewModel item = new CaseOccupationViewModel();
                item.OccupationId = i;
                item.CaseId = i;
                item.Occupation = "occupation.Occupation" + i.ToString();
                item.JobDuties = "occupation.JobDuties" + i.ToString();

                occupations.Add(item);
            }
            //if (!string.IsNullOrEmpty(text))
            //{
            //    items = items.Where(p => p.CaseId == caseId && p.Occupation.Contains(text));
            //}

            return Json(occupations);
        }
    }
}
