public HttpResponseMessage GetTimeSlots(int codeCampId) { try { var slotsToOrder = TimeSlotDataAccess.GetItems(codeCampId); var timeSlots = TimeSlotInfoController.SortTimeSlots(slotsToOrder); var response = new ServiceResponse <List <TimeSlotInfo> > { Content = timeSlots.ToList() }; if (timeSlots == null) { ServiceResponseHelper <List <TimeSlotInfo> > .AddNoneFoundError("timeSlots", ref response); } return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson())); } catch (Exception ex) { Exceptions.LogException(ex); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE)); } }
public HttpResponseMessage GetAgenda(int codeCampId) { try { var agenda = new AgendaInfo(); agenda.CodeCamp = CodeCampDataAccess.GetItem(codeCampId, ActiveModule.ModuleID); if (agenda.CodeCamp != null) { var slotsToOrder = TimeSlotDataAccess.GetItems(codeCampId); var timeSlots = TimeSlotInfoController.SortTimeSlots(slotsToOrder); var timeSlotCount = timeSlots.Count(); // determine how many days the event lasts for agenda.NumberOfDays = (int)(agenda.CodeCamp.EndDate - agenda.CodeCamp.BeginDate).TotalDays + 1; // iterate through each day agenda.EventDays = new List <EventDayInfo>(); var dayCount = 0; while (dayCount <= agenda.NumberOfDays - 1) { var eventDate = agenda.CodeCamp.BeginDate.AddDays(dayCount); var eventDay = new EventDayInfo() { Index = dayCount, Day = eventDate.Day, Month = eventDate.Month, Year = eventDate.Year, TimeStamp = eventDate }; eventDay.TimeSlots = new List <AgendaTimeSlotInfo>(); // iterate through each timeslot foreach (var timeSlot in timeSlots) { var slot = new AgendaTimeSlotInfo(timeSlot); if (!timeSlot.SpanAllTracks) { // iterate through each session slot.Sessions = SessionDataAccess.GetItemsByTimeSlotIdByPage(slot.TimeSlotId, codeCampId, dayCount + 1, timeSlotCount).ToList(); // iterate through each speaker foreach (var session in slot.Sessions) { session.Speakers = SpeakerDataAccess.GetSpeakersForCollection(session.SessionId, codeCampId); } } else { // add the full span session item // TODO: allow for items to be added to full span timeslots } eventDay.TimeSlots.Add(slot); } agenda.EventDays.Add(eventDay); dayCount++; } } var response = new ServiceResponse <AgendaInfo> { Content = agenda }; if (agenda.CodeCamp == null) { ServiceResponseHelper <AgendaInfo> .AddNoneFoundError("AgendaInfo", ref response); } return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson())); } catch (Exception ex) { Exceptions.LogException(ex); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE)); } }