using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using GridMultipleSelection.Models;
using Infragistics.Web.Mvc;

namespace GridMultipleSelection.Controllers
{
    public class HomeController : Controller
    {
        private List<Product> data = new List<Product>();

        public ActionResult Index()
        {
            SetData();
            return View(data.AsQueryable());
        }

        void SetData()
        {
            data.Add(new Product() { Name = "Dress", ProductId = 1, Cost = 342, Number = 24, Distributor = "Ben&Jean" });
            data.Add(new Product() { Name = "Shoes", ProductId = 2, Cost = 94, Number = 36, Distributor = "Dreams Ltd." });
            data.Add(new Product() { Name = "Scarf", ProductId = 3, Cost = 15, Number = 3, Distributor = "Lenna Ltd." });
            data.Add(new Product() { Name = "Jeans", ProductId = 4, Cost = 54, Number = 34, Distributor = "Dreams Ltd." });
            data.Add(new Product() { Name = "Tshirt", ProductId = 5, Cost = 20, Number = 28, Distributor = "Lenna Ltd." });
            data.Add(new Product() { Name = "Skirt", ProductId = 6, Cost = 34, Number = 30, Distributor = "BenJean" });
        }

        [HttpPost]
        public ActionResult GetIDs(FormCollection collection)
        {
            Infragistics.Web.Mvc.GridModel m = new Infragistics.Web.Mvc.GridModel();

            string[] selectedPKs = collection.Get("selectedRowsPKs").Split(',');

            // Custom code adding the new or editted elements to the database
            return View("Index");
        }
    }
}
