예제 #1
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));
            }
        }
예제 #2
0
        public HttpResponseMessage CreateSessionSpeaker(SessionSpeakerInfo speaker)
        {
            try
            {
                SessionSpeakerDataAccess.CreateItem(speaker);

                var sessionSpeakers = SessionSpeakerDataAccess.GetItems(speaker.SessionId);

                var sessionSpeaker =
                    sessionSpeakers.OrderByDescending(s => s.SessionSpeakerId).FirstOrDefault(s => s.SpeakerId == speaker.SpeakerId);

                var response = new ServiceResponse <SessionSpeakerInfo> {
                    Content = sessionSpeaker
                };

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