using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using KendoCoreMenuSeparator.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;


namespace KendoCoreMenuSeparator.Controllers
{
    public class HomeController : Controller
    {

        public override void OnActionExecuting(ActionExecutingContext context)
        {
            if (!string.IsNullOrEmpty(context.HttpContext.Request.Query["culture"]))
            {
                CultureInfo.DefaultThreadCurrentCulture = CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo(context.HttpContext.Request.Query["culture"]);
            }
            base.OnActionExecuting(context);
        }

        public IActionResult Index()
        {
            MenuCollection model = new MenuCollection();
            List<MenuViewModel> list = new List<MenuViewModel>();
            list.Add(new MenuViewModel()
            {
                MenuId = 1,
                ParentMenuId = 0,
                MenuTitle = "Home"
            });
            list.Add(new MenuViewModel()
            {
                MenuId = 2,
                ParentMenuId = 0,
                MenuTitle = "Leads"
            });
            list.Add(new MenuViewModel()
            {
                MenuId = 3,
                ParentMenuId = 0,
                MenuTitle = "Customers"
            });
            list.Add(new MenuViewModel()
            {
                MenuId = 4,
                ParentMenuId = 0,
                MenuTitle = "Opportunities"
            });
            list.Add(new MenuViewModel()
            {
                MenuId = 5,
                ParentMenuId = 3,
                MenuTitle = "New Customer",
                IsHeader= true
            });
            list.Add(new MenuViewModel()
            {
                MenuId = 6,
                ParentMenuId = 3,
                MenuTitle = ""
            });
            list.Add(new MenuViewModel()
            {
                MenuId = 7,
                ParentMenuId = 3,
                MenuTitle = "Recent Customers",
                IsHeader = true
            });
            list.Add(new MenuViewModel()
            {
                MenuId = 8,
                ParentMenuId = 3,
                MenuTitle = "Name 1"
            });
            list.Add(new MenuViewModel()
            {
                MenuId = 9,
                ParentMenuId = 3,
                MenuTitle = "Name 2"
            });
            list.Add(new MenuViewModel()
            {
                MenuId = 10,
                ParentMenuId = 3,
                MenuTitle = "Name 3",
            });
            list.Add(new MenuViewModel()
            {
                MenuId = 11,
                ParentMenuId = 3,
                MenuTitle = ""
            });
            list.Add(new MenuViewModel()
            {
                MenuId = 12,
                ParentMenuId = 3,
                MenuTitle = "My Customers",
                IsHeader = true
            });
            model.Menus = list;
            return View(model);
        }

        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();
        }
    }
}
