コード例 #1
0
        public async Task <ActionResult <IEnumerable <Status> > > GetAvailableEnrolmentStatuses(int enrolleeId)
        {
            var enrollee = await _enrolleeService.GetEnrolleeAsync(enrolleeId);

            if (enrollee == null)
            {
                return(NotFound(new ApiResponse(404, $"Enrollee not found with id {enrolleeId}")));
            }

            // if the user is not an ADMIN, make sure the enrolleeId matches the user, otherwise return not authorized
            if (!BelongsToEnrollee(enrollee))
            {
                return(Forbid());
            }

            var availableEnrolmentStatuses = await _enrolleeService.GetAvailableEnrolmentStatusesAsync(enrolleeId);

            return(Ok(new ApiOkResponse <IEnumerable <Status> >(availableEnrolmentStatuses)));
        }