Following this tutorial and my question, now I can't get the events from my database. The model:
public class Event
{
public virtual int id { get; set; }
public virtual string title { get; set; }
public virtual DateTime start { get; set; }
public virtual DateTime end { get; set; }
}
The controller:
public class EventController : ApiController
{
private SGPContext db = new SGPContext();
// GET api/event
public IQueryable GetEvents()
{
return db.Events;
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
db.Dispose();
}
base.Dispose(disposing);
}
}
And the view:
<div id="fullcalendar"></div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
<script type="text/javascript">
$(function () {
$('#fullcalendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay'
},
defaultDate: new Date(),
events: "/api/event/"
});
});
</script>
}
I have this in the database:
id:1
title:test
start:25/08/2016 09:00:00
end:25/08/2016 13:00:00
I already saw some questions and answers about not showing the content of the database but I think everything I saw was a bit different from what I have. What's missing in my code?