Beispiel #1
0
        public IHttpActionResult DeleteLecture(int lecture_id)
        {
            var lecture = LectureHelper.GetById(lecture_id);
            var deleted = lecture.Delete();

            return(Ok(new ApiCallbackMessage(deleted ? "Success" : "Falied", deleted)));
        }
Beispiel #2
0
        // GET: Lectures/courseId
        public ActionResult Index(int courseId)
        {
            var lectures = LectureHelper.GetLecturesForCourse(courseId);

            ViewBag.CourseID = courseId;

            return(View(lectures));
        }
        public static DetailedOverviewForStudentVM CreateDetailedOverviewForStudentVM(User user, Course course)
        {
            var vm = new DetailedOverviewForStudentVM(user, course)
            {
                AttendedLectures = LectureHelper.GetAllAttendedLecturesForStudent(course.CourseID, user.UserID),
                AllLectures      = LectureHelper.GetLecturesForCourse(course.CourseID)
            };

            return(vm);
        }
Beispiel #4
0
        public static DetailedCourseVM CreateDetailedCourseVMW(Course course)
        {
            var vm = new DetailedCourseVM(course)
            {
                Supervisors  = SupervisorHelper.GetSupervisorsForCourse(course.CourseID),
                Lectures     = LectureHelper.GetLecturesForCourse(course.CourseID),
                Participants = UserHelper.GetParticipantsForCourse(course.CourseID)
            };

            return(vm);
        }
Beispiel #5
0
        public IHttpActionResult RescheduleLecture(int lecture_id, int times)
        {
            var lecture = LectureHelper.GetById(lecture_id);

            for (int i = 0; i < times; i++)
            {
                var new_lec = new Lecture(lecture.From.AddDays(7 * (i + 1)), lecture.To.AddDays(7 * (i + 1)),
                                          lecture.CourseID);
                new_lec.Insert();
            }

            return(Ok(new ApiCallbackMessage("Success", true)));
        }
Beispiel #6
0
        public void AddAttendee(int lectureId, string email)
        {
            var user = UserHelper.GetByEmail(email);

            if (user == null)
            {
                return;
            }
            var lecture       = LectureHelper.GetById(lectureId);
            var studentStatus = CourseHelper.GetStudentStatusForCourse(user.UserID, lecture.CourseID);

            if (studentStatus == Participant.STATUS_ACTIVE)
            {
                var attendee = new Attendee(user.UserID, lectureId, "");
                attendee.Insert();
            }
        }
Beispiel #7
0
        // GET: Lectures/Edit/courseId&lectureId
        public ActionResult Edit(int courseId, int?lectureId)
        {
            if (lectureId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Lecture lecture = LectureHelper.GetById((int)lectureId);

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

            ViewBag.Attendees = AttendeeHelper.GetAttendeesForLecture((int)lectureId);

            return(View(lecture));
        }
Beispiel #8
0
        // GET: Lectures/Details/courseId&lectureId
        public ActionResult Details(int courseId, int?lectureId)
        {
            if (lectureId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            // cast the nullable obj to int
            int id = (int)lectureId;

            Lecture lecture = LectureHelper.GetById(id);

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

            ViewBag.Attendees = AttendeeHelper.GetAttendeesForLecture(id);

            return(View(lecture));
        }
Beispiel #9
0
        public ActionResult Delete(int courseId, int?lectureId)
        {
            if (lectureId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Lecture lecture = LectureHelper.GetById((int)lectureId);

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

            var success = lecture.Delete();

            ViewBag.Success  = success;
            ViewBag.CourseID = courseId;

            return(View());
        }
Beispiel #10
0
        // GET: Courses/Details/courseId
        // returns details view with all related data depending on the logged in user
        public ActionResult Details(int?courseId)
        {
            if (courseId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            // cast nullable int
            int    id     = (int)courseId;
            Course course = CourseHelper.GetById(id);

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

            DetailedCourseVM viewModel = null;

            // check if the current user is a student and setup accordingly the view model
            if (CurrentWebContext.CurrentUser.Type == "student")
            {
                ViewBag.IsParticipant = false;
                viewModel             = new DetailedCourseVM(course);
                viewModel.Lectures    = LectureHelper.GetLecturesForCourse(course.CourseID);
                // get the type of student for this course
                ViewBag.StatusOfStudent = CourseHelper.GetStudentStatusForCourse(CurrentWebContext.CurrentUser.UserID, course.CourseID);
            }

            // check if the current user is a teacher and create the view model for him
            if (CurrentWebContext.CurrentUser.Type == "teacher")
            {
                viewModel = DetailedCourseVM.CreateDetailedCourseVMW(course);
                ViewBag.CountOfPendingStudents = ParticipantHelper.GetCountOfPendingParticipants(id);
            }
            return(View(viewModel));
        }
Beispiel #11
0
 public void DeleteLecture(int lectureId)
 {
     LectureHelper.DeleteLecture(lectureId);
 }