File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
DigitalLearningSolutions.Web/Controllers/TrackingSystem/CourseSetup Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -651,11 +651,20 @@ private IActionResult SaveSectionAndRedirect(SetSectionContentViewModel model)
651651 {
652652 data . SectionContentData = new List < SectionContentTempData > ( ) ;
653653 }
654- if ( data . EditCourseContent )
654+ var sectionsToRemove = new List < SectionContentTempData > ( ) ;
655+ foreach ( var section in data . SectionContentData )
655656 {
656- return RedirectToNextSectionOrSummary (
657- model . Index ,
658- new SetCourseContentViewModel ( data . CourseContentData ! ) ) ;
657+ section . Tutorials = section . Tutorials
658+ . Where ( t => ! model . Tutorials . Any ( newT => newT . TutorialId == t . TutorialId ) )
659+ . ToList ( ) ;
660+ if ( ! section . Tutorials . Any ( ) )
661+ {
662+ sectionsToRemove . Add ( section ) ;
663+ }
664+ }
665+ foreach ( var section in sectionsToRemove )
666+ {
667+ data . SectionContentData . Remove ( section ) ;
659668 }
660669 data ! . SectionContentData ! . Add (
661670 new SectionContentTempData (
You can’t perform that action at this time.
0 commit comments