private JObject GetEventJson(EntityListEvent @event) { var json = new JObject { { "id", @event.EntityReference.Id.ToString() }, { "class", "event-info" }, { "title", @event.Summary }, { "start", ToUnixMilliseconds(@event.Start) }, { "end", ToUnixMilliseconds(@event.End.GetValueOrDefault(@event.Start)) }, { "description", @event.Description }, { "location", @event.Location }, }; if (!string.IsNullOrEmpty(@event.Url)) { json["url"] = @event.Url; } if (@event.Organizer != null) { json["organizer"] = new JObject { { "name", @event.Organizer.Name }, { "email", @event.Organizer.Email }, }; } if (@event.TimeZoneDisplayMode == EntityListTimeZoneDisplayMode.SpecificTimeZone && @event.TimeZone != null) { json["timezoneoffset"] = (long)@event.TimeZone.GetUtcOffset(@event.Start).TotalMilliseconds; json["timezonedisplayname"] = @event.TimeZone.DisplayName; } return(json); }
private VEvent GetVEvent(EntityListEvent @event) { var vevent = new VEvent { Uid = "{0}@{1}".FormatWith(@event.EntityReference.Id, Request.Url.Host), Start = @event.Start, End = @event.End, Timestamp = DateTime.UtcNow, Summary = @event.Summary, Description = VCalendar.StripHtml(@event.Description), DescriptionHtml = @event.Description, Location = @event.Location, Url = string.IsNullOrEmpty(@event.Url) ? null : new UrlBuilder(@event.Url).ToString() }; if (@event.Organizer != null) { vevent.Organizer = VCalendar.FormatOrganizer(@event.Organizer.Name, @event.Organizer.Email); } return(vevent); }