using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using SchedulerDemoCustomEditor.Models;

namespace SchedulerDemoCustomEditor.Controllers
{
    public class SchedulerController : Controller
    {
        [HttpGet]
        public  JsonResult Read()
        {
            List<MeetingViewModel> data = new List<MeetingViewModel> {
                new MeetingViewModel {
                    Title = "Meeting 1",
                    Start = DateTime.Now.AddHours(1),
                    End= DateTime.Now.AddHours(3)
                },
                new MeetingViewModel {
                    Title= "Meeting 2",
                    Start= DateTime.Now.AddDays(1).AddHours(1),
                    End= DateTime.Now.AddDays(1).AddHours(4)
                }};



            return Json(data);

        }
        [HttpPost]
        public  JsonResult Destroy(MeetingViewModel task)
        {
            if (ModelState.IsValid)
            {
                //... handle delete of task
            }

            return Json(task);
        }
        [HttpPost]
        public  JsonResult Create(IEnumerable<MeetingViewModel> models)
        {
            if (ModelState.IsValid)
            {
                //... handle create of task
            }

            return Json(models);
        }
        [HttpPost]
        public  JsonResult Update(MeetingViewModel task)
        {
            if (ModelState.IsValid)
            {
                //... handle update of task
            }

            return Json(task);
        }
    }
}
