Esempio n. 1
0
        public string CourseBackground(string courseId)
        {
            var course = _courseService.GetCourse(courseId);

            if (course == null)
            {
                return("");
            }
            return(string.IsNullOrEmpty(course.Background) ? "~/Images/DefaultImages/DefaultCourseBackground.jpg" : $"~/Files/CourseBackgrounds/{course.Background}");
        }
Esempio n. 2
0
        public void AddNewLecture(string courseId, bool intro)
        {
            var course           = _courseService.GetCourse(courseId);
            var lectures         = _courseService.GetCourseLectures(courseId);
            var lastLecture      = lectures.OrderByDescending(x => x.Date).Where(x => !x.Introduction).ToList()[1];
            var lastIntroLecture = lectures.OrderBy(x => x.Number).Where(x => x.Introduction).Take(1).SingleOrDefault();

            if (lastLecture == null || course == null)
            {
                return;
            }

            var lectureNumber = lastLecture.Number + 2;

            if (intro)
            {
                if (lastIntroLecture == null)
                {
                    lectureNumber = 0;
                }
                else
                {
                    lectureNumber = lastIntroLecture.Number - 1;
                }
            }

            var newLecture = new Lecture()
            {
                Course = course, Day = lastLecture.Day, Date = lastLecture.Date.AddDays(7), From = lastLecture.From, To = lastLecture.To,
                Number = lectureNumber, Introduction = intro
            };

            if (intro)
            {
                newLecture.Title = "intro";
            }

            _context.Add(newLecture);
            _context.SaveChanges();
        }
 public bool IsCourseTeacher(ClaimsPrincipal user, string courseId)
 {
     return(user != null && _courseService.GetCourse(courseId).TeacherId == GetUserId(user));
 }                                                                                                                                                           //ToDo :: I don't know if the teacher Id is already included