daily pastebin goal
19%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 40 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top