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

namespace SchedulerBasicCore.Controllers
{
    public class SchedulerController : Controller
    {
        private IList<ScheduleViewModel> GetAll()
        {
            IList<ScheduleViewModel> tasks = new List<ScheduleViewModel>();

           
            tasks = new List<ScheduleViewModel>()
                {
                    new ScheduleViewModel() {
                        EventId = 1,
                        Start = DateTime.Now,
                        End = DateTime.Now.AddHours(3),
                        Title = "First task",
                        RoomID = 1
                    },
                    new ScheduleViewModel() {
                        EventId = 2,
                        Start = DateTime.Now.AddHours(2),
                        End = DateTime.Now.AddHours(4),
                        Title = "Second task",
                        RoomID = 2
                    },
                    new ScheduleViewModel() {
                        EventId = 3,
                        Start = DateTime.Now.AddHours(26),
                        End = DateTime.Now.AddHours(30),
                        Title = "Third task",
                        RoomID = 3
                    }
                };            

            return tasks;
        }

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

        public JsonResult Resources([DataSourceRequest] DataSourceRequest request)
        {
            List<Room> rooms = new List<Room>() {
                new Room(){Value = 1, Color = "#1c9ec4", Text = "Room 1"},
                new Room(){Value = 2, Color = "#ff7663", Text = "Room 2" },
                new Room(){Value = 3, Color = "purple", Text = "Room 3"}
            };
            return Json(rooms.ToDataSourceResult(request));
        }
    }
}