public async Task <IActionResult> CreateSession(StudySessionViewModel sessionModel)
        {
            var sessionManager = _context.ManagerFactory.CreateSessionManager();

            var studySessionModel = new StudySessionModel()
            {
                SessionName = sessionModel.SessionName,
                StudyId     = sessionModel.StudyId,
                Surveys     = sessionModel.SelectedSurveys.ToList(),
                IsStarted   = false
            };

            await sessionManager.CreateStudySession(studySessionModel);

            var studyManager = _context.ManagerFactory.CreateExternalDbManager();

            var userIdList = studyManager.GetParticipantIds(sessionModel.StudyId);
            var model      = await sessionManager.GetStudySession(studySessionModel.StudyId, studySessionModel.SessionName);

            Parallel.ForEach(userIdList, x => sessionManager.CreateUserSession(new UserSession()
            {
                ParticipantId  = x,
                StudySessionId = model.Id
            }));

            return(RedirectToAction("AllStudies", "Study"));
        }
        public IActionResult CreateSession(int studyId, string studyName)
        {
            var sessionModel = new StudySessionViewModel {
                StudyId = studyId, AllSurveys = GetAllSurveyNamesList()
            };

            ViewBag.studyName = studyName;

            return(View(sessionModel));
        }
        public IActionResult SessionDetails(int studyId, string sessionName, string studyName)
        {
            var manager      = _context.ManagerFactory.CreateSessionManager();
            var sessionModel = manager.GetStudySession(studyId, sessionName).Result;


            var sessionViewModel = new StudySessionViewModel()
            {
                SessionName     = sessionModel.SessionName,
                StudyId         = sessionModel.StudyId,
                AllSurveys      = GetAllSurveyNamesList(),
                SelectedSurveys = sessionModel.Surveys,
                IsStarted       = sessionModel.IsStarted
            };

            ViewBag.studyName = studyName;

            return(View(sessionViewModel));
        }