How to get events from database with FullCalendar v4 using ASP.NET Core?

I’m trying to get the events that I’ve saved in my database to show at the calendar.

As you can see, the database saving part is OK.

Database Table Event Content

But when I try to get all these events from database using the following code,

                type: "GET",
                url: "/Escala/GetEvents",
                success: function (data) {
                    $.each(data, function (i, v) {
                            eventID: v.EventID,
                            title: v.Titulo,
                            start: moment(v.Inicio),
                            end: v.Fim != null ? moment(v.Fim) : null,
                            color: v.Cor,
                            allDay: v.DiaInteiro
                error: function (error) {

… I get some console errors


This is the /Escala/GetEvents function I’m using to get them:

        public System.Web.Mvc.JsonResult GetEvents()
            var events = _context.Eventos.ToList();
            return new System.Web.Mvc.JsonResult { Data = events, JsonRequestBehavior = JsonRequestBehavior.AllowGet };

Do you have any idea how I can fix it? Thanks in advance!

Archive from:

Leave a Reply

Your email address will not be published. Required fields are marked *