using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
using Microsoft.AspNetCore.Mvc;
using SchedulerAddResources.Models;
using System;
using System.Collections.Generic;
using System.Linq;

namespace SchedulerAddResources.Controllers
{
    public class SchedulerController : Controller
    {
        private IList<EventViewModel> GetAll()
        {

            var tasks = new List<EventViewModel>()
                {
                    new EventViewModel() {
                        Id = 1,
                        Start = DateTime.Now,
                        AttendeeID =  1 ,
                        End = DateTime.Now.AddHours(3),
                        Title = "First task"
                    },
                    new EventViewModel() {
                        Id = 2,
                        Start = DateTime.Now.AddHours(2),
                        AttendeeID =  2 ,
                        End = DateTime.Now.AddHours(4),
                        Title = "Second task"
                    }
                };
            return tasks;
        }
        public List<SchedulerResourceModel> Get_Attendees()
        {
            var attendees = new List<SchedulerResourceModel>
            {
                    new SchedulerResourceModel { Name = "Alex", AttendeeID = 1, Color = "#f8a398" },
                    new SchedulerResourceModel { Name = "Bob", AttendeeID = 2, Color = "#51a0ed" },
                    new SchedulerResourceModel { Name = "Charlie", AttendeeID = 3, Color = "#56ca85" }
            }.ToList();

            return attendees;
        }

        public IActionResult Schedules_Read([DataSourceRequest] DataSourceRequest request)
        {
            return Json(GetAll().ToDataSourceResult(request));
        }
    }
}
