コード例 #1
0
        // GET: Courses/Delete/courseId
        // returns delete view with confirmation of the course being deleted
        public ActionResult Delete(int?courseId)
        {
            if (courseId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var    id     = (int)courseId;
            Course course = CourseHelper.GetById(id);

            if (course == null)
            {
                return(HttpNotFound());
            }

            var isSupervisor = SupervisorHelper.IsUserSupervisor(CurrentWebContext.CurrentUser.UserID, id);

            if (!isSupervisor)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
            }

            ViewBag.Title = course.CourseName;

            var success = course.Delete();

            ViewBag.Success = success;

            return(View());
        }
コード例 #2
0
        // GET: Courses/SeeDetailedOverview/courseId&studentId
        // returns detailed overviev view for the specified student and targeted course
        public ActionResult SeeDetailedOverview(int courseId, int studentId)
        {
            Course course  = CourseHelper.GetById(courseId);
            User   student = UserHelper.GetById(studentId);

            if (course == null || student == null)
            {
                return(HttpNotFound());
            }

            var isSupervisor = SupervisorHelper.IsUserSupervisor(CurrentWebContext.CurrentUser.UserID, courseId);

            if (!isSupervisor)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
            }

            ViewBag.AttendancePerformance = ParticipantHelper.GetParticipantAttendance(student.UserID, course.CourseID);

            var vm = DetailedOverviewForStudentVM.CreateDetailedOverviewForStudentVM(student, course);

            return(View(vm));
        }