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
    {       
        [HttpGet]
        public DataSourceResult Schedules_Read([DataSourceRequest] DataSourceRequest request)
        {
            return GetAll().ToDataSourceResult(request);
        }

        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(5),
                        End = DateTime.Now.AddHours(6),
                        Title = "Third task",
                        RoomID = 3
                    }
                };

            return tasks;
        }

    }
}