<EjsSchedule TValue="AppointmentData" Height="650px" SelectedDate="new DateTime(2018, 5, 14)">
<ScheduleEventSettings DataSource="@DataSource"></ScheduleEventSettings>
</EjsSchedule>
@code{
List<AppointmentData> DataSource = new List<AppointmentData>
{
new AppointmentData { Id = 1, Subject = "Paris", StartTime = new DateTime(2018, 5, 13, 10, 0, 0) , EndTime = new DateTime(2018, 5, 13, 12, 0, 0) },
new AppointmentData { Id = 2, Subject = "Germany", StartTime = new DateTime(2018, 5, 15, 10, 0, 0) , EndTime = new DateTime(2018, 5, 15, 12, 0, 0) }
};
public class AppointmentData
{
public int Id { get; set; }
public string Subject { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
}
}
public void OnActionCompleted(ActionEventArgs<AppointmentData> args)
{
if (args.RequestType == "eventCreated")
{
args.AddedRecords.ForEach(app =>
{
var newEvent = new AppointmentData();
newEvent.StartTime = app.StartTime.ToLocalTime();
newEvent.EndTime = app.EndTime.ToLocalTime();
newEvent.Subject = app.Subject;
newEvent.Description = app.Description;
newEvent.Id = app.Id;
db.CalendarEvents.Add(newEvent);
});
db.SaveChanges();
}
…
} |