using C1.Web.Mvc;
using C1.Web.Mvc.Serializition;
using Microsoft.AspNet.Mvc;
using System.Collections.Generic;
using MvcExplorer.Models;
using Microsoft.AspNet.Http;

namespace MvcExplorer.Controllers
{
    public partial class FlexGridController : Controller
    {
        private readonly ControlOptions _gridPagingModel = new ControlOptions
        {
            Options = new OptionDictionary
            {
                {"Page Size", new OptionItem {Values = new List<string> {"10", "25", "50", "100"}, CurrentValue = "25"}},
            }
        };

        public ActionResult Paging(IFormCollection data)
        {
            _gridPagingModel.LoadPostData(data);
            ViewBag.DemoOptions = _gridPagingModel;
            return View();
        }

        public ActionResult Paging_Bind([C1JsonRequest] CollectionViewRequest<Sale> requestData)
        {
            return this.C1Json(CollectionViewHelper.Read(requestData, Sale.GetData(500)));
        }
    }
}
