我正在使用FullCalendar,特别是SmartAdmin随附的一种。我需要从数据库中获取事件并将其显示在日历上。
这是我需要更改为Asp.Net C#服务器端(带有LINQ的实体框架)的示例代码:
events: [
{
title: 'Event Title',
start: new Date(y, m, 10, 00, 30),
description: 'Long Description',
className: ["event", "bg-color-red"],
icon: 'fa-clock-o'
}
更新:最新的工作包括使用JSON,尝试使FullCalendar读取并显示它。
[System.Web.Services.WebMethod]
private string LoadEventLog()
{
using (DBEntities context = new DBEntities())
{
var query = (from el in context.EventLog
join et in context.EventTypes on el.eventType_FK equals et.id
join usr in context.Users on el.users_FK equals usr.id
orderby el.rowCreatedDT descending
select new EventLogInfo2()
{
id = el.id,
eventType_FK = el.eventType_FK,
eventType = et.eventType,
rowCreatedDT = el.rowCreatedDT,
message = el.message,
userFullName = usr.name + " " + usr.lastName
});
return (new JavaScriptSerializer()).Serialize(query.ToList());
}
}
返回:
[{“ id”:3,“ eventType_FK”:4,“ eventType”:“日历”,“ rowCreatedDT”:“ /日期(1544997181613)/”,“消息”:“描述测试3.”,“ userFullName“:”系统管理员“},{” id“:2,” eventType_FK“:1,” eventType“:”信息“,” rowCreatedDT“:” /日期(1544994918530)/“,”消息“:”描述测试2。“,” userFullName“:”系统管理员“},{” id“:1,” eventType_FK“:1,” eventType“:”信息“,” rowCreatedDT“:” / Date(1544994006240)/“,”消息“:”描述测试1。“,” userFullName“:”系统管理员“}]