Exemplo n.º 1
0
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var ratingService = new FeedbackService();

            var course  = _courseRepository.GetSingleFullCourse(id);
            var teacher = await _manager.FindByIdAsync(course.TeacherID);

            var currentUser = await _manager.GetUserAsync(User);

            if (course == null || teacher == null)
            {
                return(NotFound());
            }

            bool raterMarker     = ratingService.CheckIfCourseRaterValid(_manager.GetUserId(User), _context, course);
            bool subscribeMarker = ratingService.CheckIfValidToSubscribe(course.Title, _userRepository.GetUserWithLessonsList(currentUser.Id));

            return(View(new DetailsViewModel()
            {
                Course = course, Teacher = teacher, isReadtForRate = raterMarker, IsValidForSubscribe = subscribeMarker
            }));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> FinalSearchByName(string searchString)
        {
            Course course = new Course();

            if (!String.IsNullOrEmpty(searchString))
            {
                course = _context.Course.Include(x => x.TeacherInfo).Include(x => x.Marks).Include(y => y.WeekPlans).Include(x => x.Duration).FirstOrDefault(x => x.Title.Equals(searchString));
            }
            var ratingService = new FeedbackService();
            var currentUser   = await _manager.GetUserAsync(User);

            bool raterMarker     = ratingService.CheckIfCourseRaterValid(_manager.GetUserId(User), _context, course);
            bool subscribeMarker = ratingService.CheckIfValidToSubscribe(course.Title, _userRepository.GetUserWithLessonsList(currentUser.Id));

            return(View("../Courses/Details", new DetailsViewModel()
            {
                Course = course, isReadtForRate = raterMarker, IsValidForSubscribe = subscribeMarker
            }));
        }