using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Telerik.Web.Mvc;
using GridAjaxPagingExample.Models;

namespace GridAjaxPagingExample.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View(Data());
        }

        [AcceptVerbs(HttpVerbs.Post)]
        [GridAction]
        public ActionResult IndexAjax()
        {
            return View(new GridModel(Data()));
        }

        /// <summary>
        /// provides data
        /// </summary>
        /// <returns></returns>
        private List<ExampleModel> Data()
        {
            List<ExampleModel> vColData = new List<ExampleModel>();
            ExampleModel vObjExample = null;
            for (int i = 0; i < 100; i++)
            {
                vObjExample = new ExampleModel()
                {
                    Id = i,
                    Name = string.Format("Name of {0}", i),
                    LastName = string.Format("LastName of {0}", i),
                    PhoneNumber = string.Format("{0}", 100 + i)
                };
                vColData.Add(vObjExample);
            }
            return vColData;
        }

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