Our team is utilizing fullcalendar.io and aiming to retrieve an event from our API controller.
The Controller
[Route("api/Bookings")]
public class BookingApiController
{
// GET
[HttpGet]
public string Get()
{
var returnJson = new
{
events = new[]
{
new {title = "bro", start = "2018-05-06"},
new {title = "bro2", start = "2018-05-05"}
}
};
return JsonConvert.SerializeObject(returnJson);
}
}
Our javascript file
$ ( function () {
$('# calendar '). fullCalendar({
// weekends: false
dayClick: function ( date ) {
window.location.href = "/Booking/Booking? selectedDate =" + date.format ();
},
eventSources: [
{
url: '/ api / Booking',
color: 'yellow', // a option!
textColor: 'black' // a option!
}
]
})
});
However, the JavaScript script fails to receive the event correctly. Although it does obtain the JSON data, it doesn't add the event accurately to the calendar.