using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Kendo.Mvc.UI;
using Kendo.Mvc.Extensions;
using KendoUIMVC5.Models;

namespace KendoUIMVC5.Controllers
{
    public class HomeController : Controller
    {

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

        [HttpPost]
        public ActionResult GetSessionsView(UserToSend usertosend)
        {

            return PartialView("GridPartial", usertosend);
        }


        public ActionResult SessionsRead([DataSourceRequest] DataSourceRequest request, UserToSend usertosend)
        {

            List<SessiondataDTO> sdto = new List<SessiondataDTO>();
            sdto.Add(new SessiondataDTO { ApplicationName = "testapplication", FarmName = "testFarm", DomainName = "MS", Id = 1, ServerName = "server01", UserId = usertosend.UserId, SessionId = 01 });
            sdto.Add(new SessiondataDTO { ApplicationName = "testapplication4", FarmName = "testFarm", DomainName = "MS", Id = 2, ServerName = "server02", UserId = usertosend.UserId, SessionId = 18 });
            sdto.Add(new SessiondataDTO { ApplicationName = "testapplication3", FarmName = "testFarm", DomainName = "MS", Id = 3, ServerName = "server12", UserId = usertosend.UserId, SessionId = 15 });
            sdto.Add(new SessiondataDTO { ApplicationName = "testapplication7", FarmName = "testFarm", DomainName = "MS", Id = 4, ServerName = "server00", UserId = usertosend.UserId, SessionId = 8 });


            DataSourceResult result = sdto.ToDataSourceResult(request);

            return Json(result, JsonRequestBehavior.AllowGet);
        }
    }
}


