public async Task <ActionResult> GetEnrollees([FromQuery] EnrolleeSearchOptions searchOptions)
        {
            if (User.HasAdminView())
            {
                return(Ok(ApiResponse.Result(await _enrolleeService.GetEnrolleesAsync(searchOptions))));
            }
            else
            {
                var enrollee = await _enrolleeService.GetEnrolleeForUserIdAsync(User.GetPrimeUserId());

                return(Ok(ApiResponse.Result(enrollee == null ? Enumerable.Empty <Enrollee>() : new[] { enrollee })));
            }
        }
Exemplo n.º 2
0
        public async Task <ActionResult <IEnumerable <Enrollee> > > GetEnrollees([FromQuery] EnrolleeSearchOptions searchOptions)
        {
            IEnumerable <Enrollee> enrollees = null;

            // User must have the RO_ADMIN or ADMIN role to see all enrollees
            if (User.IsAdmin() || User.HasAdminView())
            {
                enrollees = await _enrolleeService.GetEnrolleesAsync(searchOptions);
            }
            else
            {
                var enrollee = await _enrolleeService.GetEnrolleeForUserIdAsync(User.GetPrimeUserId());

                enrollees = (enrollee != null) ? new[] { enrollee } : new Enrollee[0];
            }

            return(Ok(ApiResponse.Result(enrollees)));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> GetEnrollees([FromQuery] EnrolleeSearchOptions searchOptions)
        {
            if (User.HasAdminView())
            {
                var notifiedIds = await _enrolleeService.GetNotifiedEnrolleeIdsForAdminAsync(User);

                var enrollees = await _enrolleeService.GetEnrolleesAsync(searchOptions);

                var result = enrollees.Select(e => e.SetNotification(notifiedIds.Contains(e.Id)));
                return(Ok(ApiResponse.Result(result)));
            }
            else
            {
                var enrollee = await _enrolleeService.GetEnrolleeForUserIdAsync(User.GetPrimeUserId());

                return(Ok(ApiResponse.Result(enrollee == null ? Enumerable.Empty <Enrollee>() : new[] { enrollee })));
            }
        }
Exemplo n.º 4
0
        public async Task <ActionResult <IEnumerable <Enrollee> > > GetEnrollees(
            [FromQuery] EnrolleeSearchOptions searchOptions)
        {
            IEnumerable <Enrollee> enrollees = null;

            // User must have the ADMIN role to see all enrollees
            if (User.IsInRole(PrimeConstants.PRIME_ADMIN_ROLE))
            {
                enrollees = await _enrolleeService.GetEnrolleesAsync(searchOptions);
            }
            else
            {
                var enrollee = await _enrolleeService.GetEnrolleeForUserIdAsync(User.GetPrimeUserId());

                enrollees = new List <Enrollee>();

                if (enrollee != null)
                {
                    enrollees = enrollees.Append(enrollee);
                }
            }

            return(Ok(new ApiOkResponse <IEnumerable <Enrollee> >(enrollees)));
        }