using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using KendoUIMvcApplication1.Models;
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;

namespace KendoUIMvcApplication1.Controllers
{
    public class PatientController : Controller
    {

        public ActionResult Grid()
        {
            ViewData["treatments"] = CreatePhase();
            return View(Getpatient());
        }

        private PatientCollection Getpatient()
        {
            PatientCollection patientCollection = new PatientCollection();
            List<PatientModel> obj = new List<PatientModel>();
            PatientModel patient = new PatientModel();
            patient.patientID = 12;
            patient.treatment = CreatePhase();
            obj.Add(patient);
            patientCollection.patientCollection = obj;

            return patientCollection;
        }

        private List<Treatment> CreatePhase()
        {
            List<Treatment> TreatmentCollection = new List<Treatment>();
            TreatmentCollection.Add(new Treatment { treatmentID = 1, treatment = "PreTreatment" });
            TreatmentCollection.Add(new Treatment { treatmentID = 2, treatment = "PostTreatment" });

            return TreatmentCollection;


        }



        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Patient_Read([DataSourceRequest]DataSourceRequest request, PatientModel patient)
        {


            return Json((Getpatient().patientCollection).ToDataSourceResult(request));

        }


        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Patient_Update([DataSourceRequest] DataSourceRequest request, PatientModel patient)
        {
            if (Request.Form != null)
            {
                int patientID = Convert.ToInt32(Request.Form["PatientID"]);
                string patientName = Request.Form["Treatment"];


            }
            return Json(new[] { patient }.ToDataSourceResult(request, ModelState));
        }

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Patient_Create([DataSourceRequest] DataSourceRequest request, PatientModel patient)
        {


            return Json(new[] { patient }.ToDataSourceResult(request, ModelState));
        }


        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Patient_Delete([DataSourceRequest] DataSourceRequest request, PatientModel patient)
        {

            return Json(new[] { patient }.ToDataSourceResult(request, ModelState));
        }


    }
}
