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

namespace SampleCoreApp.Controllers
{
    public class SampleEnumsController : Controller
    {
		private static List<MyData> data = new List<MyData>
		{
			new MyData{ID = 1, Name = "name 1", SomeField = MyCategoryEnum.First},
			new MyData{ID = 2, Name = "name 2", SomeField = MyCategoryEnum.Second},
			new MyData{ID = 3, Name = "name 3", SomeField = MyCategoryEnum.Third}
		};
 
        public ActionResult Index()
        {
            return View();
        }

		public ActionResult EditingInline_Read([DataSourceRequest] DataSourceRequest request)
		{
			return Json(data.ToDataSourceResult(request));
		}

		//note: actual CRUD operations are not implemented here

		[AcceptVerbs("Post")]
		public ActionResult EditingInline_Create([DataSourceRequest] DataSourceRequest request, MyData product)
		{
			return Json(new[] { product }.ToDataSourceResult(request, ModelState));
		}

		[AcceptVerbs("Post")]
		public ActionResult EditingInline_Update([DataSourceRequest] DataSourceRequest request, MyData product)
		{
			return Json(new[] { product }.ToDataSourceResult(request, ModelState));
		}

		[AcceptVerbs("Post")]
		public ActionResult EditingInline_Destroy([DataSourceRequest] DataSourceRequest request, MyData product)
		{
			return Json(new[] { product }.ToDataSourceResult(request, ModelState));
		}
	}
}