private void addOrUpdateSessionData(int dddEventId, DDDEventDetail eventDetail, string userName, string userToken, string clientToken, IList<PocketDDD.Models.UserSessionData> sessionData)
        {
            if (sessionData == null || sessionData.Count() == 0)
                return;

            var eventScoreService = LazyLoadEventScoreService(userToken, userName, dddEventId);
            var token = userToken ?? clientToken;

            var userSessionDatas = sessionData.Select(x => new PocketDDD.Models.Azure.UserSessionData
            {
                PartitionKey = dddEventId.ToString(),
                RowKey = x.sessionId.ToString() + "_" + token,
                SessionId = x.sessionId,
                UserName = userName,
                UserToken = userToken,
                ClientToken = clientToken,
                Bookmarked = x.bookmarked,
                AttendingStatus = x.attendingStatus,
                SpeakerKnowledgeRating = x.speakerKnowledgeRating,
                SpeakerSkillsRating = x.speakerSkillsRating
            });

            foreach (var sessionDataItem in sessionData)
            {
                var session = eventDetail.Sessions.First(x => x.Id == sessionDataItem.sessionId);

                if (sessionDataItem.bookmarked || sessionDataItem.attendingStatus != 2)
                    eventScoreService.AddBookmarkOrAttendingItem(session.TimeSlotId);

                if(sessionDataItem.speakerKnowledgeRating != null)
                    eventScoreService.AddKnowledgeRatingItem(session.TimeSlotId);

                if (sessionDataItem.speakerSkillsRating != null)
                    eventScoreService.AddSkillRatingItem(session.TimeSlotId);
            }

            TableBatchOperation batch = new TableBatchOperation();
            foreach (var userSessionData in userSessionDatas)
            {
                batch.InsertOrReplace(userSessionData);
            }
            userSessionDataTable.ExecuteBatch(batch);
        }
        private IList<AcceptedUserComment> addComments(string type, int dddEventId, DDDEventDetail eventDetail, string userName, string userToken, string clientToken, IList<UserComment> userComments)
        {
            if (userComments == null || userComments.Count == 0)
                return null;

            var eventScoreService = LazyLoadEventScoreService(userToken, userName, dddEventId);
            var token = userToken ?? clientToken;
            var comments = userComments.Select(x => new Comment
            {
                PartitionKey = dddEventId.ToString(),
                RowKey = type + token + "_" + x.id + "",
                SessionId = x.sessionId,
                Type = type,
                UserName = userName,
                UserToken = userToken,
                ClientToken = clientToken,
                UserComment = x.comment,
                Date = x.date
            });

            foreach (var comment in userComments)
            {
                if (comment.sessionId != null)
                {
                    var session = eventDetail.Sessions.First(x => x.Id == comment.sessionId);
                    eventScoreService.AddCommentItem(type, session.TimeSlotId);
                }
                else
                {
                    eventScoreService.AddCommentItem(type, null);
                }
            }

            TableBatchOperation batch = new TableBatchOperation();
            foreach (var comment in comments)
            {
                batch.InsertOrReplace(comment);
            }
            userCommentsTable.ExecuteBatch(batch);

            var accepted = userComments.Select(x => new AcceptedUserComment
            {
                eventId = dddEventId,
                id = x.id,
                sessionId = x.sessionId
            });

            return accepted.ToList();
        }