using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.Linq;
using System.Web;
using System.Web.Mvc;
using GridAndTabStrip.Models;
using Telerik.Web.Mvc;

namespace GridAndTabStrip.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewData["Message"] = "Welcome to ASP.NET MVC!";

            return View();
        }

        public ActionResult About()
        {
            return View();
        }

        public ActionResult LoadOnDemandDocument()
        {
            return PartialView();
        }

        public ActionResult GridAndTabStrip()
        {
            return View(new NWDataContext());
        }

        public ActionResult GridLoadOnDemand()
        {
            var nw = new NWDataContext();
            return PartialView(nw.Employees.ToList());
        }

        [GridAction]
        public ActionResult _AjaxBinding()
        {
            NWDataContext nw = new NWDataContext();
            return View(new GridModel<Employee>
            {
                Data = nw.Employees
            });
        }

        public ActionResult PostBackGridInTabStrip(int? tabIndex)
        {
            ViewData["tabIndex"] = tabIndex ?? 0;
            NWDataContext nw = new NWDataContext();
            return View(nw.Employees.ToList());
        }
    }
}
