Guest User

Untitled

a guest
Jun 13th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. public ActionResult iCal(int id) {
  2.  
  3. MyApp.Event kiEvt = evR.Get(id);
  4.  
  5. // Create a new iCalendar
  6. iCalendar iCal = new iCalendar();
  7.  
  8. // Create the event, and add it to the iCalendar
  9. DDay.iCal.Components.Event evt = iCal.Create<DDay.iCal.Components.Event>();
  10.  
  11. // Set information about the event
  12. evt.Start = kiEvt.event_date;
  13. evt.End = evt.Start.AddHours(kiEvt.event_duration); // This also sets the duration
  14. evt.Description = kiEvt.description;
  15. evt.Location = kiEvt.place;
  16. evt.Summary = kiEvt.title;
  17.  
  18. // Serialize (save) the iCalendar
  19. iCalendarSerializer serializer = new iCalendarSerializer(iCal);
  20.  
  21.  
  22. System.IO.MemoryStream fs = new System.IO.MemoryStream();
  23.  
  24. serializer.Serialize(fs, System.Text.Encoding.UTF8);
  25.  
  26. return File(fs, "text/calendar", "MyApp.wyd."+kiEvt.id+".ics");
  27. }
  28.  
  29. fs.Seek(0, 0);
Add Comment
Please, Sign In to add comment