You can access the Controller using "Controller" property from within the Dpc class. Given that the user id is available as User.Identity.Name you can use something like this to filter the events:
protected override void OnFinish()
{
if (UpdateType == CallBackUpdateType.None)
{
return;
}
Events = from ev in db.Calendars where ev.UserID == Controller.User.Identity.Name select ev;
DataIdField = "ID";
DataTextField = "Text";
DataStartField = "Start";
DataEndField = "End";
}
Note that in real-world scenarios you will also want to limit the selected events by the visible range:
protected override void OnFinish()
{
if (UpdateType == CallBackUpdateType.None)
{
return;
}
Events = from ev in db.Calendars where ev.UserID == Controller.User.Identity.Name && !((e.End <= VisibleStart) || (e.Start >= VisibleEnd))select ev;
DataIdField = "ID";
DataTextField = "Text";
DataStartField = "Start";
DataEndField = "End";
}
Note that VisibleStart and VisibleEnd properties are available since version 8.2.5836 (in previous version you can use StartDate and StartDate.AddDays(Days) instead).
See also the latest version of the MVC5 Event Calendar tutorial:
https://code.daypilot.org/59860/asp-net-mvc-5-event-calendar