using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using Telerik.SvgIcons;
using TelerikAspNetCoreApp675.Data;

namespace TelerikAspNetCoreApp675.Pages
{
    public class IndexModel : PageModel
    {
        public static IList<OrderViewModel> orders;


        public void OnGet()
        {
            if (orders == null)
            {
                orders = new List<OrderViewModel>();

                Enumerable.Range(0, 50).ToList().ForEach(i => orders.Add(new OrderViewModel
                {
                    OrderID = i + 1,
                    Freight = i * 10,
                    OrderDate = new DateTime(2016, 9, 15).AddDays(i % 7),
                    ShipName = "ShipName " + i,
                    ShipCity = "ShipCity " + i
                }));

            }
        }

        public JsonResult OnGetCLINTaskTypes(int? ddlCLIN)
        {
            var data = Enumerable.Range(1, 100).Select(x => new ProjectViewModel()
            {
                Title = "Project " + x,
                ProjectID = x
            });

            if (ddlCLIN != null)
            {
                data = data.Where(p => p.ProjectID % ddlCLIN == 0);
            }

            var dsResult = data;//.ToDataSourceResult(request);
            return new JsonResult(dsResult);


        }
        public JsonResult OnGetCLINS()
        {
            var data = Enumerable.Range(1, 10).Select(x => new ProjectViewModel()
            {
                Title = "Project " + x,
                ProjectID = x
            });


            var dsResult = data;//.ToDataSourceResult(request);
            return new JsonResult(dsResult);
        }
    }
}
