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

CRUD operations not working


I'm following this tutorial to add CRUD operations to the scheduler: https://ej2.syncfusion.com/aspnetcore/documentation/schedule/data-binding/#performing-crud-actions

The problem is that this tutorial is a little bit outdated and some things changes in .NET Core.

1. For example, JsonRequestBehavior has been deprecated in ASP.NET Core 1.0.

2. In UpdateData method inside the Controller, the class EditParams doesn't exist. 

3. Another thing is that when I execute the method 'GetData' to get appointment data, the method is executed twice (checked it with a break-point inside Visual Studio) and after the return, nothing is added to the scheduler.

No error is shown in the browser console.

This is the DataManager setup:

@using Syncfusion.EJ2
    var ValidationRules = new Dictionary() { { "required", true } };
    var DateValidation = new Dictionary() { { "required", true } };
    var dataManager = new DataManager() { Url = "GetData", Adaptor = "UrlAdaptor", CrudUrl = "UpdateData", CrossDomain = true };

This is my GetData method:

        public async Task GetData()
            var schedule = await GetScheduleData(DateTime.Now.ToString("dd/MM/yyyy"), null, User.Identity.Name);

            return Json(schedule);

There is an updated tutorial for CRUD operations in .NET Core? 

Can you help me?

21 Replies

VD Vinitha Devi Murugan Syncfusion Team April 1, 2019 01:20 PM UTC

Hi Gregory, 
Thank you for contacting Syncfusion Support. 
1.We have prepared the sample in core 2.1 with Json- formatted data, which can be downloaded from the following link.  
2.We have already logged task for revamping the EJ2 Core UG, and we will include the reported scenarios also with that. And this will be refreshed online on 10th April, 2019. 
3. By default post will hit twice. 
  1. A pre-flight request with the OPTIONS method is sends, so that the can respond whether it is acceptable to send the request with this parameters.  
  2. Then the actual request is sent that will be a POST request method, which will retrieve the scheduler data.
Kindly check whether any data available in schedule variable and share your GetScheduleData method to proceed further. 
  public async Task GetData() 
            var schedule = await GetScheduleData(DateTime.Now.ToString("dd/MM/yyyy"), null, User.Identity.Name); 
            return Json(schedule); 
M.Vinitha devi. 

GP Gregory Perozzo April 1, 2019 02:34 PM UTC

Hello Vinitha!

I have downloaded your sample and I'm following it.

I'm still having problems to show the data on the scheduler.

The 'schedule' variable has data on it. I double check it.

This is my method to get the data:

        public async Task LoadData()
            var schedule = await GetScheduleData(DateTime.Now.ToString("dd/MM/yyyy"), null, User.Identity.Name);

            return Json(schedule);

The GetScheduleData method returns a list of ScheduleEvent: 

        Task> GetScheduleData(string date, Schedule schedule, string username)

The ScheduleEvent is:

    public class ScheduleEvent
        public int Id { get; set; }
        public string Subject { get; set; }
        public string Date { get; set; }
        public DateTime StartTime { get; set; }
        public DateTime EndTime { get; set; }
        public string StartTimezone { get; set; }
        public string EndTimezone { get; set; }
        public bool IsAllDay { get; set; }
        public string Status { get; set; }
        public string Plate { get; set; }
        public string Workload { get; set; }
        public string ListStudent { get; set; }
        public string ListTeacher { get; set; }
        public string ListVehicle { get; set; }
        public string ListWorkload { get; set; }
        public string Color { get; set; }
        public bool IsReadonly { get; set; }

And this is the ejs schedule setup (Not able to put the code here. I think the editor think is a html code to render. So I uploaded an image.):

GP Gregory Perozzo April 1, 2019 02:54 PM UTC

Hello Vinitha,

In your sample, inside DbInitializer class some data is loaded to the appointments. I changed the date to 2019, but nothing is shown either on the scheduler.

        public static void Initialize(ScheduleDataContext context)

            // Look for any students.
            if (context.ScheduleEvents.Any())
                return;   // DB has been seeded

            var appointments = new ScheduleEvent[]
            new ScheduleEvent{Id=1, Subject="Meeting", StartTime= new DateTime(2019,3,27,10,00,00), EndTime=new DateTime(2019,3,27,11,00,00),  IsAllDay=false},
            new ScheduleEvent{Id=2, Subject="Client Demo", StartTime= new DateTime(2019,3,28,10,00,00), EndTime=new DateTime(2019,3,28,11,00,00),  IsAllDay=false},

            foreach (ScheduleEvent app in appointments)

I think this is related to a problem in the scheduler itself to render the data.

GP Gregory Perozzo April 3, 2019 12:53 PM UTC


Any updates on this issue?

NR Nevitha Ravi Syncfusion Team April 3, 2019 04:38 PM UTC

Hi Gregory, 
Thanks for your update. 
We have analysed the provided code details and we suspect that the issue might be due to any of your customization within the application which hidden the appointment. Can you please provide us the following details so that we could able replicate the issue and provide you a solution at earlier. 
  • Share the response screenshot of LoadData method in network tab.
  • Can you please share us the customization codes done in sample.
We have attached the sample in which we have tested the issue. Please check this sample and if the issue persists on your side please modify the sample based o your scenario and revert us . 
M.Vinitha devi. 

GP Gregory Perozzo April 3, 2019 05:09 PM UTC

Hello Nevitha!

1. Share the response screenshot of LoadData method in network tab.

  •  Json

[{"id":110228,"subject":"ALUNO GREGORY 3 (871.235.520-83)","date":"quarta-feira, 3 de abril de 2019","startTime":"2019-04-03T10:39:00","endTime":"2019-04-03T11:29:00","startTimezone":null,"endTimezone":null,"isAllDay":false,"status":"Agendada","plate":"BLE-0001","workload":"50 minutos","listStudent":"ALUNO GREGORY 3 (871.235.520-83)","listTeacher":"INSTRUTOR RENAN (727.945.716-99)","listVehicle":"BLE-0001","listWorkload":"50 minutos","color":"#4d79ff","isReadonly":false}]

2. Can you please share us the customization codes done in sample.

Sorry, I don't understand. What customization?


I will check your new sample and try to execute it here.

Thank you very much!

GP Gregory Perozzo April 3, 2019 05:24 PM UTC


When running your example, I have the following error on Main method:

Cannot insert explicit value for identity column in table 'ScheduleEvent' when IDENTITY_INSERT is set to OFF.

So, I changed the GetData() method to this:

And the scheduler loaded perfectly.

So now, I'll do my customization in your sample and check if it works.

Thanks for now.

GP Gregory Perozzo April 3, 2019 06:52 PM UTC


I think I discovered the problem.

The data was not showing in the scheduler due to the date format I'm using.

I changed your sample to get the data as my project does.

This is what I am using:

                DateTime start = Convert.ToDateTime($"{item.SchedulingDate} {item.SchedulingHour}") = {3/4/2019 10:00:00 AM};
                DateTime end = item.WorkloadID == 1 ? start.AddMinutes(50) : start.AddMinutes(100) = {3/4/2019 11:00:00 AM};

And this is what your sample uses:

                 StartTime = new DateTime(2019, 4, 3, 10, 00, 00) = {4/3/2019 10:00:00 AM};
                 EndTime = new DateTime(2019, 4, 3, 11, 00, 00) = {4/3/2019 11:00:00 AM} ;

This change, only worked in your sample. In my sample, still not working.

But in my project, I changed the date format: