Save new event

Hi, mi question is...
Theres some way to save the events automatically to a Python API? let me explain this...

I have a Python API able to read the JSON file that I obtain from scheduleObj.dataSource, the thing is...
When I could conect that to automatize with mi Python API?

Consider that my api reads the json perfectly and I get the data I need, but I need that as soon as I save, update or delete this it sends to call my api

1 Reply 1 reply marked as answer

HB Hareesh Balasubramanian Syncfusion Team March 3, 2021 01:10 PM UTC

Hi Kanaissa, 

Greetings from Syncfusion Support..! 

We have prepared a CRUD sample based on your shared query “CRUD actions are not working properly” using UrlAdaptor and also we have ensured the CRUD actions (creating/editing/deleting) of the Scheduler events are properly working, which can be viewed from the following link. 

 
Client-side snippet: 
  public eventSettings: EventSettingsModel = { 
    dataSource: new DataManager({ 
      url: 'http://localhost:54738/Home/LoadData', // Here need to mention the web api sample running path 
      crudUrl: 'http://localhost:54738/Home/UpdateData', 
      crossDomain: true, 
      adaptor: new UrlAdaptor 
    }) 
  } 

Server-side snippet
public JsonResult LoadData(Params param)  // Here we get the Start and End Date and based on that can filter the data and return to Scheduler 
                var data = db.ScheduleEventDatas.Where(app => (app.StartTime >= param.StartDate && app.StartTime <= param.EndDate) || (app.RecurrenceRule != null && app.RecurrenceRule != "")).ToList();  // Here filtering the events based on the start and end date value. 
                return Json(data, JsonRequestBehavior.AllowGet); 
public class Params 
                public DateTime StartDate { get; set; } 
                public DateTime EndDate { get; set; } 
[HttpPost] 
public JsonResult UpdateData(EditParams param) 
                if (param.action == "insert" || (param.action == "batch" && param.added != null)) // this block of code will execute while inserting the appointments 
                { 
                                var value = (param.action == "insert") ? param.value : param.added[0]; 
                                int intMax = db.ScheduleEventDatas.ToList().Count > 0 ? db.ScheduleEventDatas.ToList().Max(p => p.Id) : 1; 
                                DateTime startTime = Convert.ToDateTime(value.StartTime); 
                                DateTime endTime = Convert.ToDateTime(value.EndTime); 
                                ScheduleEventData appointment = new ScheduleEventData() 
                                { 
                                   Id = intMax + 1, 
                                                StartTime = startTime, 
                                                EndTime = endTime, 
                                                Subject = value.Subject, 
                                                Location = value.Location, 
                                                Description = value.Description, 
                                                IsAllDay = value.IsAllDay, 
                                                StartTimezone = value.StartTimezone, 
                                                EndTimezone = value.EndTimezone, 
                                                RecurrenceRule = value.RecurrenceRule, 
                                                RecurrenceID = value.RecurrenceID, 
                                                RecurrenceException = value.RecurrenceException 
                                }; 
                                db.ScheduleEventDatas.InsertOnSubmit(appointment); 
                                db.SubmitChanges(); 
                } 
                if (param.action == "update" || (param.action == "batch" && param.changed != null)) // this block of code will execute while updating the appointment 
                { 
                                var value = (param.action == "update") ? param.value : param.changed[0]; 
                                var filterData = db.ScheduleEventDatas.Where(c => c.Id == Convert.ToInt32(value.Id)); 
                                if (filterData.Count() > 0) 
                                { 
                                                DateTime startTime = Convert.ToDateTime(value.StartTime); 
                                                DateTime endTime = Convert.ToDateTime(value.EndTime); 
                                                ScheduleEventData appointment = db.ScheduleEventDatas.Single(A => A.Id == Convert.ToInt32(value.Id)); 
                                                appointment.StartTime = startTime; 
                                                appointment.EndTime = endTime; 
                                                appointment.StartTimezone = value.StartTimezone; 
                                                appointment.EndTimezone = value.EndTimezone; 
                                                appointment.Subject = value.Subject; 
                                                appointment.Location = value.Location; 
                                                appointment.Description = value.Description; 
                                                appointment.IsAllDay = value.IsAllDay; 
                                                appointment.RecurrenceRule = value.RecurrenceRule; 
                                                appointment.RecurrenceID = value.RecurrenceID; 
                                                appointment.RecurrenceException = value.RecurrenceException; 
                                } 
                                db.SubmitChanges(); 
                } 
                if (param.action == "remove" || (param.action == "batch" && param.deleted != null)) // this block of code will execute while removing the appointment 
                { 
                                if (param.action == "remove") 
                                { 
                                                int key = Convert.ToInt32(param.key); 
                                                ScheduleEventData appointment = db.ScheduleEventDatas.Where(c => c.Id == key).FirstOrDefault(); 
                                                if (appointment != null) db.ScheduleEventDatas.DeleteOnSubmit(appointment); 
                                } 
                                else 
                                { 
                                                foreach (var apps in param.deleted) 
                                                { 
                                                                ScheduleEventData appointment = db.ScheduleEventDatas.Where(c => c.Id == apps.Id).FirstOrDefault(); 
                                                                if (apps != null) db.ScheduleEventDatas.DeleteOnSubmit(appointment); 
                                                } 
                                } 
                                db.SubmitChanges(); 
                } 
                var data = db.ScheduleEventDatas.ToList(); 
                return Json(data, JsonRequestBehavior.AllowGet); 

Kindly try the above solution and get back to us if you need any further assistance. 

We will happy to assist you..! 

Regards, 
Hareesh 


Marked as answer
Loader.
Up arrow icon