Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ActionResult iCal(int id) {
- MyApp.Event kiEvt = evR.Get(id);
- // Create a new iCalendar
- iCalendar iCal = new iCalendar();
- // Create the event, and add it to the iCalendar
- DDay.iCal.Components.Event evt = iCal.Create<DDay.iCal.Components.Event>();
- // Set information about the event
- evt.Start = kiEvt.event_date;
- evt.End = evt.Start.AddHours(kiEvt.event_duration); // This also sets the duration
- evt.Description = kiEvt.description;
- evt.Location = kiEvt.place;
- evt.Summary = kiEvt.title;
- // Serialize (save) the iCalendar
- iCalendarSerializer serializer = new iCalendarSerializer(iCal);
- System.IO.MemoryStream fs = new System.IO.MemoryStream();
- serializer.Serialize(fs, System.Text.Encoding.UTF8);
- return File(fs, "text/calendar", "MyApp.wyd."+kiEvt.id+".ics");
- }
- fs.Seek(0, 0);
Add Comment
Please, Sign In to add comment