// GET: HelpQueue/HelpQueue/{id?}
        public async Task <ActionResult> Queue(int?id)
        {
            var service = new CohortService(User.Identity.GetUserId());

            CohortDetail model = null;

            if (User.IsInRole("Student"))
            {
                model = await service.GetUserCohortDetailAsync(User.Identity.GetUserId());

                if (model is null)
                {
                    return(RedirectToAction(nameof(InactiveAccount)));
                }
            }
            else if (id.HasValue)
            {
                model = await service.GetCohortById(id.Value);
            }

            if (model is null)
            {
                return(RedirectToAction(nameof(Index)));
            }

            return(View(model));
        }
예제 #2
0
        // Get Cohort
        public async Task <CohortDetail> GetCohortById(int cohortId)
        {
            var cohortEntity = await _context.Cohorts.FindAsync(cohortId);

            if (cohortEntity == null)
            {
                return(null);
            }

            var cohortDetail = new CohortDetail
            {
                CohortId   = cohortEntity.Id,
                CohortName = cohortEntity.Name
            };

            cohortDetail.Students  = await new EnrollmentService().GetEnrollmentByCohortIdAsync(cohortId);
            cohortDetail.Questions = await new QuestionService(_userId).GetQuestionsByCohortId(cohortId);

            return(cohortDetail);
        }