public ActionResult PrevNextButtons(string courseId, int slideIndex, bool onSolutionsSlide) { var course = courseManager.GetCourse(courseId); var slide = course.Slides[slideIndex]; var userId = User.Identity.GetUserId(); var nextIsAcceptedSolutions = !onSolutionsSlide && slide is ExerciseSlide && visitersRepo.IsSkippedOrPassed(slide.Id, userId); var visibleUnits = unitsRepo.GetVisibleUnits(courseId, User); var nextSlide = course.Slides.FirstOrDefault(s => s.Index > slideIndex && visibleUnits.Contains(s.Info.UnitName)); var prevSlide = course.Slides.LastOrDefault(s => s.Index < slideIndex && visibleUnits.Contains(s.Info.UnitName)); var model = new PrevNextButtonsModel(course, slideIndex, nextIsAcceptedSolutions, nextSlide == null ? -1 : nextSlide.Index, prevSlide == null ? -1 : prevSlide.Index); if (onSolutionsSlide) model.PrevSlideIndex = model.SlideIndex; return PartialView(model); }
public ActionResult PrevNextButtons(string courseId, Guid slideId, bool onSolutionsSlide) { var course = courseManager.GetCourse(courseId); var slide = course.GetSlideById(slideId); var userId = User.Identity.GetUserId(); var nextIsAcceptedSolutions = !onSolutionsSlide && slide is ExerciseSlide && visitsRepo.IsSkippedOrPassed(slide.Id, userId) && !((ExerciseSlide)slide).Exercise.HideShowSolutionsButton; var visibleUnits = unitsRepo.GetVisibleUnits(courseId, User); var nextSlide = course.Slides.FirstOrDefault(s => s.Index > slide.Index && visibleUnits.Contains(s.Info.UnitName)); var prevSlide = course.Slides.LastOrDefault(s => s.Index < slide.Index && visibleUnits.Contains(s.Info.UnitName)); var model = new PrevNextButtonsModel( course, slide.Id, nextIsAcceptedSolutions, nextSlide, prevSlide, !User.Identity.IsAuthenticated); if (onSolutionsSlide) model.PrevSlide = slide; return PartialView(model); }