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 async Task CreateStudySession(StudySessionModel studySessionModel)
        {
            var studySessionCollection = _db.GetCollection <StudySessionModel>("study_session_collection");

            var studySession = new StudySessionModel
            {
                SessionName = studySessionModel.SessionName,
                StudyId     = studySessionModel.StudyId,
                Surveys     = studySessionModel.Surveys,
            };

            await studySessionCollection.InsertOneAsync(studySession);
        }
        public async Task DeleteSession(StudySessionModel studySessionModel)
        {
            var studySessionCollection = _db.GetCollection <StudySessionModel>("study_session_collection");

            await studySessionCollection.DeleteOneAsync(x => x.Id == studySessionModel.Id);
        }