I am currently attempting to implement DayPilot Lite MVC on my project. I've set up my events and they are clickable(tested with a Debug statement). However what i am looking to do is process the click and load a new View, using a ViewModel built from the id of the event I clicked.
public ActionResult Booking()
{
ApplicationDbContext db = new ApplicationDbContext();
int id = Dpc.eventID;
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Lesson lesson = db.Lessons.Find(id);
if (lesson == null)
{
return HttpNotFound();
}
return View(lesson);
}
class Dpc : DayPilotCalendar
{
public int eventID;
protected override void OnInit(InitArgs e)
{
ApplicationDbContext db = new ApplicationDbContext();
Events = from ev in db.Lessons select ev;
DataIdField = "ClassID";
DataTextField = "ClassLevel";
DataStartField = "ClassStartDate";
DataEndField = "ClassEndDate";
Update();
}
protected override void OnEventClick(EventClickArgs e)
{
//Test to check the method was firing
Debug.WriteLine("Hey I clicked you");
//Parse the event ID for processing
eventID = int.Parse(e.Id);
//Redirect to the booking page
Redirect("Schedule/Booking");
}
}
When I tried to code the Booking method, it resulted in telling me that Dpc.eventID needs an object reference. I have tried making the class and the variable public, but the error persists. I can't make the eventClick public as then i can't override the original. I'm using Redirect because if i try any other link it fails for the same reason. I'm guessing it's because it's a non-inherited subclass, but should i not still be able to access its member attributes if they have a public scope?