We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Schedule Control Resources and Appointment Management

Hello,

I've been working this week on trying to figure out how to use the schedule control. I have some basic functionality down, but I am struggling with a few items. 

I am attempting to model your sample app located at http://mvc.syncfusion.com/demos/web/AppointmentPlanner/Home/Index.

I love the way this looks and feels, but am having a hard time wring everything up correctly. 

I'm trying to load in a list of resources from an employees table containing the following fields:
employeeId
firstname
lastname
Title
phone

I want to be able to create appointments for patients from the patient table:
patientId
FirstName
LastName
ownerId


I'd also like to be able to create a new patient record and add it to the patient table. 

Appointments are currently being created in DefaultSchedule table. 

The appointment should be for the patient and the owner should be the employee resource selected when creating the appointment.  

Here is my controller code:

 List<String> resources = new List<String>();
            resources.Add("Owners");
            ViewBag.Resources = resources;
            return View();

        public ActionResult GetData()
        {
            IEnumerable data = new PPDB2Entities().DefaultSchedules.Take(100); // nw.Appointment.Take(5);
            return Json(data, JsonRequestBehavior.AllowGet);
        }

        public JsonResult GetResources()
        {
            IEnumerable data = new PPDB2Entities().Employees.Take(100);
            return Json(data, JsonRequestBehavior.AllowGet);
        }

My View:

@{
    ViewBag.Title = "Home Page";
}

@(Html.EJ().Schedule("Schedule1")
     .Width("100%")
     .Height("525px")
          .Resources(res => { res.Field("employeeId").Title("Owner").Name("Owners").AllowMultiple(true).ResourceSettings(flds => flds.Datasource(ds => ds.URL("/Home/GetResources")).Text("Text").Id("Id").Color("Color")).Add(); })
            .Group(gr =>
            {
                gr.Resources(ViewBag.Resources);
            })
            .AppointmentSettings(fields => fields.Datasource(ds => ds.URL("/Home/GetData").CrudURL("/Home/Batch").Adaptor("UrlAdaptor"))
     .Id("Id")
     .Subject("Subject")
     .Description("Description")
     .StartTime("StartTime")
     .EndTime("EndTime")
     .AllDay("AllDay")
     .Recurrence("Recurrence")
     .ResourceFields("employeeId")
     .RecurrenceRule("RecurrenceRule"))
)

The schedule control will not load at all with this code. If I populate the resources from a list instead, it does show and I can create appointments, but they do not show on the calendar for the given resource and the ownerId is not saved in the database. 




1 Reply

KK Karthigeyan Krishnamurthi Syncfusion Team February 23, 2017 01:49 PM UTC

Hi Michael, 
 
Thank you for contacting Syncfusion support. 
 
We have prepared the Appointment Planner CRUD sample which can be download from the below location. 
 
In the sample resource and Scheduler data are fetched from data source and appointment added/edited/deleted with in Scheduler will be reflected in database too. Kindly refer the below code example used in the sample. 
 
<Code> 
.Resources(res => 
                    { 
                        res.Field("RoomId").Title("Room").Name("Rooms").AllowMultiple(false) 
                           .ResourceSettings(flds => flds.Datasource(ViewBag.departmentDB).Text("Text").Id("Id").GroupId("GroupId").Color("Color")).Add(); 
                        res.Field("OwnerId").Title("Owner").Name("Owners").AllowMultiple(true) 
                            .ResourceSettings(flds => flds.Datasource(ViewBag.doctorDB).Text("text").Id("Id").GroupId("GroupId").Color("Color")).Add(); 
                    }) 
.AppointmentSettings(fields => fields.Datasource(ds => ds.URL("Home/GetHspt").CrudURL("Home/Batch").Adaptor("UrlAdaptor")) 
</Code> 
 
 
Note: In the sample, CRUD operation will be performed only for Scheduler part and not for Category, Doctors, Waiting list labeled portions. 
 
Regards, 
Karthigeyan 


Loader.
Up arrow icon