データベースからイベントをフェッチして、フルカレンダーにそれらのイベントを入力しようとしています。イベントは表示されていません。コントローラでテスト用のイベントを作成すると、表示されますが
コントローラー:この場合、イベントは表示されません
public JsonResult getEvents()
{
UserProfile user = getUserProfile();
List<Calendar> events = db.Calendars.Where(c => c.userID == user.userID).ToList();
IList<calendarPost> tasksList = new List<calendarPost>();
foreach (Calendar eve in events)
{
tasksList.Add(new calendarPost
{
id = eve.recordID,
title = eve.recordDescription,
start = ToUnixTimespan(eve.startTime),
end = ToUnixTimespan(eve.endTime),
url = "www.google.com"
// });
// }
});
}
return Json(tasksList.ToArray(), JsonRequestBehavior.AllowGet);
私がこれを行うと、イベントが表示されます:
public JsonResult getEvents()
{
UserProfile user = getUserProfile();
List<Calendar> events = db.Calendars.Where(c => c.userID == user.userID).ToList();
IList<calendarPost> tasksList = new List<calendarPost>();
// foreach (Calendar eve in events)
// {
tasksList.Add(new calendarPost
{
id = 5,
title = "test",
start = ToUnixTimespan(DateTime.Now.AddHours(1)),
end = ToUnixTimespan(DateTime.Now.AddHours(2)),
url = "www.google.com"
// });
// }
});
return Json(tasksList.ToArray() , JsonRequestBehavior.AllowGet);
}
ええとところで両方とも同じJson出力を生成します
[{"id":5,"title":"test","start":1336945877,"end":1336949477,"url":"www.google.com","backgroundColor":null}]
[{"id":1,"title":"Testing the Calendar","start":1349384400,"end":1352062800,"url":"www.google.com","backgroundColor":null},{"id":3,"title":"Testing Votes","start":1325748600,"end":1325752200,"url":"www.google.com","backgroundColor":null}]