예제 #1
0
        public HttpResponseMessage Post(List <SessionViewModel> sessionList)
        {
            List <Session> dbSessions = sessionList.Select(x => ModelConverter.ToDbSessionModel(x)).ToList();

            if (dbSessions.Count == 1)
            {
                Session session = dbSessions.First();
                if (session.Id > 0)
                {
                    sessionRepository.UpdateSession(session);
                }
                else
                {
                    session = sessionRepository.CreateSession(session);
                }
            }
            else
            {
                sessionRepository.BulkSessionUpdate(dbSessions);
            }

            // OMG FIX THIS LATER
            sessionList = sessionRepository.GetSessionList(dbSessions.First().CampaignId).Select(x => ModelConverter.ToSessionViewModel(x)).ToList();

            return(Request.CreateResponse(HttpStatusCode.OK, dbSessions));
        }