Exemple #1
0
        /// <summary>
        /// Shows the course data specified for what course the user is in and based off of
        /// the pairing.
        /// </summary>
        /// <param name="courseID"></param>
        /// <returns></returns>
        #region Handlers
        public async Task <IActionResult> OnGetAsync(int courseID)
        {
            //gets the course from the database based off of the course ID.
            Course = await _context.GetCourseAsync(courseID);

            //Gets the Client profile by passing in their username to the GetClientAsync
            //function in the applicationDbContext
            var appUser = await _context.GetClientAsync(Username);

            //Sets the appuser as a Client
            var client = appUser.Client;

            //checks to see if the course exists or if the course exists
            //if not then returns message saying not able to find course id for that specified user
            if (Course == null || client == null)
            {
                return(NotFound($"Unable to course user with ID '{courseID}' for user {Username}"));
            }

            //checks to see if the Client ID for the user matches the one associated with course
            //if not then returns error message telling the user they cannot find the user id for that
            //course
            else if (Course.Pair.ClientID != client.ID)
            {
                return(NotFound($"Unable to course user with ID '{courseID}' for user {Username}"));
            }

            else
            {
                return(Page());
            }
        }
Exemple #2
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var courseID = id.GetValueOrDefault();

            Course = await _context.GetCourseAsync(courseID);

            var appUser = await _context.GetMentorAsync(Username);

            var mentor = appUser.Mentor;

            await CheckRole(_context, _userManager, Course.Pair.JoinCode);

            if (Course == null || mentor == null)
            {
                return(NotFound($"Unable to course user with ID '{courseID}' for user {Username}"));
            }
            else if (Course.Pair.MentorID != mentor.ID)
            {
                return(NotFound($"Unable to course user with ID '{courseID}' for user {Username}"));
            }

            else
            {
                return(Page());
            }
        }
Exemple #3
0
        public async Task <IActionResult> OnGetAsync(int?courseID)
        {
            if (courseID == null)
            {
                return(NotFound());
            }

            CourseID = courseID.GetValueOrDefault();
            var course = await _context.GetCourseAsync(CourseID);


            await CheckRole(_context, _userManager, course.Pair.JoinCode);

            if (!IsMentor)
            {
                return(NotFound());
            }

            return(Page());
        }
Exemple #4
0
        public async Task <IActionResult> OnPostAsync()
        {
            var course = await _context.GetCourseAsync(Event.CourseID);

            await CheckRole(_context, _userManager, course.Pair.JoinCode);

            var success = await _context.DeleteEventAsync(Event.EventID);

            if (!success || !IsMentor)
            {
                return(RedirectToPage("/Error"));
            }

            return(RedirectToPage("/Mentor/Course/Index", new { id = Event.CourseID }));
        }