Get Sitefinity Events from API

Posted on: Wed Sep 08 18:04:39 -0700 2010. Updated on: Wed Sep 08 19:52:20 -0700 2010.
Category: Telerik Controls and Sitefinity

Here is a quick example to get sitefinity events via the API, bind them to something that is better typed and then easily output to screen.

public static Collection GetMostRecentEvents()
		{
			EventsManager eventsMgr = new EventsManager("Events");

			IList rawEvents = eventsMgr.GetEvents();

			List listOfEvents = new List();

			foreach (Telerik.Events.IEvent eventItem in rawEvents)
			{
				listOfEvents.Add(new DataTransferObjects.EventSummaryDTO(eventItem.Start, eventItem.EventTitle, eventItem.ID));
			}

			var query = from e in listOfEvents
						orderby e.StartTime descending
						select e;

			return new Collection(query.Take(4).Reverse().ToList());
		}

And the object you can easily bind with any datasource, ie a gridview, radgrid, listview, etc

public class EventSummaryDTO
	{
		public EventSummaryDTO(DateTime startTime, string eventTitle, Guid eventId)
		{
			this.EventId = eventId;
			this.EventTitle = eventTitle;
			this.StartTime = startTime;
		}

		public DateTime StartTime { get; set; }
		public string EventTitle { get; set; }
		public Guid EventId { get; set; }
	}

Comments:

Add a Comment:

simple_captcha.jpg
(human authentication)


Ads

Categories

About

Random foliage

This website is meant to be a reference for ASP Dot Net developers. The entries are a compilation of things I've figured out how to do and that I deem useful to keep of track for future reference. Assumptions: web development with: C Sharp (vb sucks), visual studio 05/08, .net 3.5, meant for programmers. Written by: James Reategui.