public ActionResult GetEvents(int type, double start, double end) { CalendarType calendarType = CalendarTypes.Where(ct => ct.id == type).FirstOrDefault(); DateTime fromDate = ConvertFromUnixTimestamp(start); DateTime toDate = ConvertFromUnixTimestamp(end); List <CalendarEvent> events = new List <CalendarEvent>(); List <string> toLoad = new List <string>(); switch (calendarType.value) { case "Followup": case "Meetings": case "Dreams": case "Goals": toLoad.Add(calendarType.value); break; case "All": default: toLoad.Add("Followup"); toLoad.Add("Meetings"); toLoad.Add("Dreams"); toLoad.Add("Goals"); break; } if (toLoad.Count > 0) { List <CalendarEvent> tempEvents = new List <CalendarEvent>(); if (toLoad.Contains("Meetings") == true) { EventbriteContext context = new EventbriteContext(eventbriteApiKey, eventbriteUserKey); Organizer organizer = context.GetOrganizer(eventbriteOrginizerId); Dictionary <long, Event> ebevents = organizer.Events; if (ebevents.Count > 0) { tempEvents = (from e in ebevents where e.Value.StartDateTime >= DateTime.Now && e.Value.EndDateTime <= toDate select new CalendarEvent(e.Value)).ToList(); events.AddRange(tempEvents); } } if (toLoad.Contains("Followup") == true) { List <ContactFollowup> followups = IBOVirtualAPI.GetFollowups(ibo.IBONum, fromDate.ToString(), toDate.ToString()); if (followups.Count > 0) { tempEvents = (from e in followups where e.datetime >= fromDate select new CalendarEvent(e)).ToList(); events.AddRange(tempEvents); } } if (toLoad.Contains("Dreams") == true) { /* TODO: Create API methods that support date filtering */ List <Dream> dreams = IBOVirtualAPI.GetDreamsUser(ibo.IBONum); if (dreams.Count > 0) { tempEvents = (from e in dreams where e.datetime >= fromDate select new CalendarEvent(e)).ToList(); events.AddRange(tempEvents); } } if (toLoad.Contains("Goals") == true) { /* TODO: Create API methods that support date filtering */ List <Goal> goals = IBOVirtualAPI.GetIBOGoals(ibo.IBONum); if (goals.Count > 0) { tempEvents = (from e in goals where e.datetime >= fromDate select new CalendarEvent(e)).ToList(); events.AddRange(tempEvents); } } } return(Json(events.ToArray(), JsonRequestBehavior.AllowGet)); }