using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
using Microsoft.AspNetCore.Mvc;
using WebApplication1.Models;

namespace WebApplication1.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult GetStudents([DataSourceRequest] DataSourceRequest request)
        {
            var students = new List<Student>() {
                new Student() {Id = 1, LastName="Last Name 1", FirstName = "FirstName 1", ReportsTo = null },
                new Student() {Id = 2, LastName="Last Name 2", FirstName = "FirstName 2", ReportsTo = 1 },
                new Student() {Id = 3, LastName="Last Name 3", FirstName = "FirstName 3", ReportsTo = 2 },
                new Student() {Id = 4, LastName="Last Name 4", FirstName = "FirstName 4", ReportsTo = 2 }
            };

            return Json(students.ToDataSourceResult(request));
        }

        public ActionResult EditStudent(Student student)
        {
            return Json(student);
        }

        public IActionResult Privacy()
        {
            return View();
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}
