namespace TelerikMvcApplication25.Controllers
{
    using System.Linq;
    using System.Web.Mvc;
    using Models;
    using Telerik.Web.Mvc;

    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View(Enumerable.Range(1, 20).Select(i => new Product {Id = i, Name = "Name" + i}));
        }

        [GridAction]
        public JsonResult Select()
        {
            return Json(new GridModel(Enumerable.Range(1, 20).Select(i => new Product { Id = i, Name = "Name" + i })));
        }
        
        public ViewResult Payment(int id)
        {
            return CreateOperationView(id, "Payment");
        }

        public ViewResult Order(int id)
        {
            return CreateOperationView(id, "Order");
        }

        private ViewResult CreateOperationView(int id, string operationName)
        {
            ViewBag.Id = id;
            ViewBag.OperationName = operationName;
            return View("Operation");
        }
    }
}