コード例 #1
0
        public HttpResponseMessage GetTimeSlot(int itemId, int codeCampId)
        {
            try
            {
                var timeSlot = TimeSlotDataAccess.GetItem(itemId, codeCampId);

                // removing this prevented the saved/retrieved time from being offset to being about 4 hours off
                //if (timeSlot != null)
                //{
                //    timeSlot.BeginTime = timeSlot.BeginTime.ToLocalTime();
                //    timeSlot.EndTime = timeSlot.EndTime.ToLocalTime();
                //}

                var response = new ServiceResponse <TimeSlotInfo> {
                    Content = timeSlot
                };

                if (timeSlot == null)
                {
                    ServiceResponseHelper <TimeSlotInfo> .AddNoneFoundError("timeSlot", ref response);
                }

                return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE));
            }
        }
コード例 #2
0
        public HttpResponseMessage DeleteTimeSlot(int itemId, int codeCampId)
        {
            try
            {
                var sessions = SessionDataAccess.GetItemsByTimeSlotId(itemId, codeCampId);

                if (sessions.Any())
                {
                    foreach (var session in sessions)
                    {
                        session.TimeSlotId          = null;
                        session.LastUpdatedByDate   = DateTime.Now;
                        session.LastUpdatedByUserId = UserInfo.UserID;

                        SessionDataAccess.UpdateItem(session);
                    }
                }

                TimeSlotDataAccess.DeleteItem(itemId, codeCampId);

                var response = new ServiceResponse <string> {
                    Content = SUCCESS_MESSAGE
                };

                return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE));
            }
        }
コード例 #3
0
        public HttpResponseMessage UpdateTimeSlot(TimeSlotInfo timeSlot)
        {
            try
            {
                var updatesToProcess = false;
                var originalTimeSlot = TimeSlotDataAccess.GetItem(timeSlot.TimeSlotId, timeSlot.CodeCampId);

                updatesToProcess = TimeSlotHasUpdates(ref originalTimeSlot, ref timeSlot);

                if (updatesToProcess)
                {
                    originalTimeSlot.LastUpdatedByDate   = DateTime.Now;
                    originalTimeSlot.LastUpdatedByUserId = UserInfo.UserID;

                    TimeSlotDataAccess.UpdateItem(originalTimeSlot);
                }

                var savedTimeSlot = TimeSlotDataAccess.GetItem(timeSlot.TimeSlotId, timeSlot.CodeCampId);

                // removing this prevented the saved/retrieved time from being offset to being about 4 hours off
                //if (savedTimeSlot != null)
                //{
                //    savedTimeSlot.BeginTime = savedTimeSlot.BeginTime.ToLocalTime();
                //    savedTimeSlot.EndTime = savedTimeSlot.EndTime.ToLocalTime();
                //}

                var response = new ServiceResponse <TimeSlotInfo> {
                    Content = savedTimeSlot
                };

                return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE));
            }
        }
コード例 #4
0
        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));
            }
        }
コード例 #5
0
        public HttpResponseMessage CreateTimeSlot(TimeSlotInfo timeSlot)
        {
            try
            {
                var timeStamp = DateTime.Now;

                timeSlot.CreatedByDate       = timeStamp;
                timeSlot.CreatedByUserId     = UserInfo.UserID;
                timeSlot.LastUpdatedByDate   = timeStamp;
                timeSlot.LastUpdatedByUserId = UserInfo.UserID;

                TimeSlotDataAccess.CreateItem(timeSlot);

                var timeSlots = TimeSlotDataAccess.GetItems(timeSlot.CodeCampId);

                var savedTimeSlot = timeSlots.OrderByDescending(s => s.CreatedByDate).FirstOrDefault(s => s.BeginTime == timeSlot.BeginTime);

                // removing this prevented the saved/retrieved time from being offset to being about 4 hours off
                //if (savedTimeSlot != null)
                //{
                //    savedTimeSlot.BeginTime = savedTimeSlot.BeginTime.ToLocalTime();
                //    savedTimeSlot.EndTime = savedTimeSlot.EndTime.ToLocalTime();
                //}

                var response = new ServiceResponse <TimeSlotInfo> {
                    Content = savedTimeSlot
                };

                return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE));
            }
        }
コード例 #6
0
        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));
            }
        }