public HttpResponseMessage GetSessionCountBySpeakerId(int codeCampId, int speakerId)
        {
            try
            {
                var allSessions     = SessionDataAccess.GetItems(codeCampId);
                var sessionSpeakers = SessionSpeakerDataAccess.GetItemsBySpeakerId(speakerId).Select(s => s.SessionId);
                var sessions        = allSessions.Where(s => sessionSpeakers.Contains(s.SessionId));

                var response = new ServiceResponse <int> {
                    Content = sessions.Any() ? sessions.Count() : 0
                };

                if (!sessions.Any())
                {
                    ServiceResponseHelper <int> .AddNoneFoundError("sessions", ref response);
                }

                return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE));
            }
        }
        public HttpResponseMessage GetRoomByTrackId(int trackId, int codeCampId)
        {
            try
            {
                RoomInfo room  = null;
                var      track = TrackDataAccess.GetItems(codeCampId).Where(t => t.TrackId == trackId).FirstOrDefault();

                if (track != null)
                {
                    room = RoomDataAccess.GetItem(track.RoomId.Value, codeCampId);
                }

                var response = new ServiceResponse <RoomInfo> {
                    Content = room
                };

                if (room == null)
                {
                    ServiceResponseHelper <RoomInfo> .AddNoneFoundError("rooms", ref response);
                }

                return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE));
            }
        }
        public HttpResponseMessage GetRegistrationByUserId(int userId, int codeCampId)
        {
            try
            {
                var response = new ServiceResponse <RegistrationInfo>();
                RegistrationInfo registration = null;

                if (userId > 0)
                {
                    registration     = RegistrationDataAccess.GetItemByUserId(userId, codeCampId);
                    response.Content = registration;
                }

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

                return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE));
            }
        }
예제 #4
0
        public HttpResponseMessage UnassignRoomFromTrack(int roomId, int trackId, int codeCampId)
        {
            try
            {
                var track = TrackDataAccess.GetItem(trackId, codeCampId);

                if (track != null)
                {
                    track.RoomId              = null;
                    track.LastUpdatedByDate   = DateTime.Now;
                    track.LastUpdatedByUserId = UserInfo.UserID;

                    TrackDataAccess.UpdateItem(track);
                }

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

                if (track == null)
                {
                    ServiceResponseHelper <string> .AddNoneFoundError("track", 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 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));
            }
        }
예제 #6
0
        public HttpResponseMessage UnassignTimeSlotFromSession(int sessionId, int timeSlotId, int codeCampId)
        {
            try
            {
                var session = SessionDataAccess.GetItem(sessionId, codeCampId);

                if (session != null)
                {
                    session.TimeSlotId          = null;
                    session.LastUpdatedByDate   = DateTime.Now;
                    session.LastUpdatedByUserId = UserInfo.UserID;

                    SessionDataAccess.UpdateItem(session);
                }

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

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

                return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE));
            }
        }
예제 #7
0
        public HttpResponseMessage GetVolunteer(int itemId, int codeCampId)
        {
            try
            {
                var volunteer = VolunteerDataAccess.GetItem(itemId, codeCampId);
                var response  = new ServiceResponse <VolunteerInfo> {
                    Content = volunteer
                };

                if (volunteer == null &&
                    (UserInfo.IsSuperUser || UserInfo.IsInRole(PortalSettings.AdministratorRoleName) ||
                     ModulePermissionController.HasModulePermission(ActiveModule.ModulePermissions, "Edit")))
                {
                    // automatically make superusers, admins, and editors a volunteer
                    response.Content = GenerateOrganizerVolunteerInfo(codeCampId);
                }
                else if (volunteer == null)
                {
                    ServiceResponseHelper <VolunteerInfo> .AddNoneFoundError("volunteer", ref response);
                }

                if (volunteer != null)
                {
                    LoadSupplementalProperties(ref volunteer);
                }

                return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE));
            }
        }
예제 #8
0
        public HttpResponseMessage GetVolunteers(int codeCampId)
        {
            try
            {
                var volunteers = VolunteerDataAccess.GetItems(codeCampId);

                volunteers = LoadSupplementalProperties(volunteers);

                var response = new ServiceResponse <List <VolunteerInfo> > {
                    Content = volunteers.ToList()
                };

                if (volunteers == null)
                {
                    ServiceResponseHelper <List <VolunteerInfo> > .AddNoneFoundError("volunteers", ref response);
                }

                return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE));
            }
        }
예제 #9
0
        public HttpResponseMessage GetSessionSpeakers(int sessionId)
        {
            try
            {
                var speakers = SessionSpeakerDataAccess.GetItems(sessionId);
                var response = new ServiceResponse <List <SessionSpeakerInfo> > {
                    Content = speakers.ToList()
                };

                if (speakers == null)
                {
                    ServiceResponseHelper <List <SessionSpeakerInfo> > .AddNoneFoundError("speakers", ref response);
                }

                return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE));
            }
        }
예제 #10
0
        public HttpResponseMessage GetSessionRegistrationByRegistrantId(int sessionId, int registrantId)
        {
            try
            {
                var registration = SessionRegistrationDataAccess.GetItems(sessionId).FirstOrDefault(r => r.RegistrationId == registrantId);
                var response     = new ServiceResponse <SessionRegistrationInfo> {
                    Content = registration
                };

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

                return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE));
            }
        }
        public HttpResponseMessage GetSession(int itemId)
        {
            try
            {
                var session  = SessionDataAccess.GetItem(itemId, ActiveModule.ModuleID);
                var response = new ServiceResponse <SessionInfo> {
                    Content = session
                };

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

                return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE));
            }
        }
        public HttpResponseMessage GetVolunteerTask(int itemId, int volunteerId)
        {
            try
            {
                var task     = VolunteerTaskDataAccess.GetItem(itemId, volunteerId);
                var response = new ServiceResponse <VolunteerTaskInfo> {
                    Content = task
                };

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

                return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE));
            }
        }
        public HttpResponseMessage GetEvents()
        {
            try
            {
                var codeCamps = CodeCampDataAccess.GetItems(ActiveModule.ModuleID);
                var response  = new ServiceResponse <List <CodeCampInfo> > {
                    Content = codeCamps.ToList()
                };

                if (codeCamps == null)
                {
                    ServiceResponseHelper <List <CodeCampInfo> > .AddNoneFoundError("CodeCampInfo", ref response);
                }

                return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE));
            }
        }
예제 #14
0
        public HttpResponseMessage GetCurrentUser()
        {
            try
            {
                var currentUser = UserInfo;
                var response    = new ServiceResponse <UserInfo> {
                    Content = UserInfo
                };

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

                return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE));
            }
        }
예제 #15
0
        public HttpResponseMessage GetTracks(int codeCampId)
        {
            try
            {
                var tracks   = TrackDataAccess.GetItems(codeCampId);
                var response = new ServiceResponse <List <TrackInfo> > {
                    Content = tracks.ToList()
                };

                if (tracks == null)
                {
                    ServiceResponseHelper <List <TrackInfo> > .AddNoneFoundError("tracks", ref response);
                }

                return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE));
            }
        }
        public HttpResponseMessage GetSpeaker(int itemId, int codeCampId)
        {
            try
            {
                var speaker  = SpeakerDataAccess.GetItem(itemId, codeCampId);
                var response = new ServiceResponse <SpeakerInfo> {
                    Content = speaker
                };

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

                return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE));
            }
        }
예제 #17
0
        public HttpResponseMessage GetTrackByRoomId(int roomId, int codeCampId)
        {
            try
            {
                var track = TrackDataAccess.GetItems(codeCampId).FirstOrDefault(t => t.RoomId == roomId);

                var response = new ServiceResponse <TrackInfo> {
                    Content = track
                };

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

                return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE));
            }
        }
        public HttpResponseMessage GetSessionsByTimeSlotId(int timeSlotId, int codeCampId)
        {
            try
            {
                var sessions = SessionDataAccess.GetItemsByTimeSlotId(timeSlotId, codeCampId);

                var response = new ServiceResponse <List <SessionInfo> > {
                    Content = sessions.ToList()
                };

                if (!sessions.Any())
                {
                    ServiceResponseHelper <List <SessionInfo> > .AddNoneFoundError("sessions", ref response);
                }

                return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE));
            }
        }
예제 #19
0
        public HttpResponseMessage GetUnassignedRooms(int codeCampId)
        {
            try
            {
                var trackList = TrackDataAccess.GetItems(codeCampId).Select(t => t.RoomId);
                var rooms     = RoomDataAccess.GetItems(codeCampId).Where(r => !trackList.Contains(r.RoomId));

                var response = new ServiceResponse <List <RoomInfo> > {
                    Content = rooms.ToList()
                };

                if (rooms == null)
                {
                    ServiceResponseHelper <List <RoomInfo> > .AddNoneFoundError("rooms", ref response);
                }

                return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE));
            }
        }
예제 #20
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));
            }
        }
        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));
            }
        }
        public HttpResponseMessage CreateRegistration(RegistrationInfo registration)
        {
            try
            {
                var response = new ServiceResponse <RegistrationInfo>();

                if (registration.UserId <= 0)
                {
                    // user isn't logged in and therefore doesn't likely have a user account on the site
                    // we need to register them into DNN for them

                    var firstName = registration.CustomPropertiesObj.FirstOrDefault(p => p.Name == "FirstName").Value;
                    var lastName  = registration.CustomPropertiesObj.FirstOrDefault(p => p.Name == "LastName").Value;
                    var email     = registration.CustomPropertiesObj.FirstOrDefault(p => p.Name == "Email").Value;
                    var portalId  = int.Parse(registration.CustomPropertiesObj.FirstOrDefault(p => p.Name == "PortalId").Value);

                    var ctlUser = new DnnUserController();
                    var status  = ctlUser.CreateNewUser(firstName, lastName, email, portalId);

                    switch (status)
                    {
                    case UserCreateStatus.DuplicateEmail:
                        ServiceResponseHelper <RegistrationInfo> .AddUserCreateError("DuplicateEmail", ref response);

                        break;

                    case UserCreateStatus.DuplicateUserName:
                        ServiceResponseHelper <RegistrationInfo> .AddUserCreateError("DuplicateUserName", ref response);

                        break;

                    case UserCreateStatus.Success:
                        var user = UserController.GetUserByName(email);
                        registration.UserId = user.UserID;

                        UserController.UserLogin(portalId, user, PortalSettings.PortalName, string.Empty, false);
                        break;

                    case UserCreateStatus.UnexpectedError:
                        ServiceResponseHelper <RegistrationInfo> .AddUserCreateError("UnexpectedError", ref response);

                        break;

                    case UserCreateStatus.UsernameAlreadyExists:
                        ServiceResponseHelper <RegistrationInfo> .AddUserCreateError("UsernameAlreadyExists", ref response);

                        break;

                    case UserCreateStatus.UserAlreadyRegistered:
                        ServiceResponseHelper <RegistrationInfo> .AddUserCreateError("UserAlreadyRegistered", ref response);

                        break;

                    default:
                        ServiceResponseHelper <RegistrationInfo> .AddUnknownError(ref response);

                        break;
                    }
                }

                if (response.Errors.Count == 0)
                {
                    registration.RegistrationDate = DateTime.Now;

                    RegistrationDataAccess.CreateItem(registration);

                    var registrations     = RegistrationDataAccess.GetItems(registration.CodeCampId).OrderByDescending(r => r.RegistrationId);
                    var savedRegistration = registrations.FirstOrDefault(r => r.UserId == registration.UserId);

                    response.Content = savedRegistration;

                    if (savedRegistration == null)
                    {
                        ServiceResponseHelper <RegistrationInfo> .AddNoneFoundError("registration", ref response);
                    }
                }

                return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson()));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE));
            }
        }