@@ -11,6 +11,7 @@ namespace DigitalLearningSolutions.Web.Services
1111 using ClosedXML . Excel ;
1212 using DigitalLearningSolutions . Data . Exceptions ;
1313 using DigitalLearningSolutions . Data . Helpers ;
14+ using DigitalLearningSolutions . Data . Models . Frameworks ;
1415 using DigitalLearningSolutions . Data . Models . Frameworks . Import ;
1516 using DocumentFormat . OpenXml . Office2010 . Excel ;
1617
@@ -125,14 +126,13 @@ CompetencyTableRow competencyRow
125126 {
126127 return maxFrameworkCompetencyGroupId ;
127128 }
128- int newCompetencyGroupId = 0 ;
129129 int newCompetencyId = 0 ;
130130 int newFrameworkCompetencyId = 0 ;
131131 //If competency group is set, check if competency group exists within framework and add if not and get the Framework Competency Group ID
132132 int ? frameworkCompetencyGroupId = null ;
133133 if ( competencyRow . CompetencyGroup != null )
134134 {
135- newCompetencyGroupId = frameworkService . InsertCompetencyGroup ( competencyRow . CompetencyGroup , competencyRow . GroupDescription , adminUserId ) ;
135+ int newCompetencyGroupId = frameworkService . InsertCompetencyGroup ( competencyRow . CompetencyGroup , competencyRow . GroupDescription , adminUserId ) ;
136136 if ( newCompetencyGroupId > 0 )
137137 {
138138 frameworkCompetencyGroupId = frameworkService . InsertFrameworkCompetencyGroup ( newCompetencyGroupId , frameworkId , adminUserId ) ;
@@ -181,10 +181,10 @@ CompetencyTableRow competencyRow
181181
182182
183183 // If flags are supplied, add them:
184- if ( competencyRow . FlagsCsv != null )
184+ if ( ! string . IsNullOrWhiteSpace ( competencyRow . FlagsCsv . Trim ( ) ) )
185185 {
186186 var flags = competencyRow . FlagsCsv . Split ( ',' ) ;
187- int [ ] flagIds = [ ] ;
187+ var flagIds = new List < int > ( ) ;
188188 foreach ( var flag in flags ) {
189189 int flagId = 0 ;
190190 var frameworkFlags = frameworkService . GetCompetencyFlagsByFrameworkId ( frameworkId , null , null ) ;
@@ -195,17 +195,22 @@ CompetencyTableRow competencyRow
195195 if ( frameworkFlag . FlagName == flag )
196196 {
197197 flagId = frameworkFlag . FlagId ;
198+ break ;
198199 }
199200 }
200201 }
201202 if ( flagId == 0 )
202203 {
203204 flagId = frameworkService . AddCustomFlagToFramework ( frameworkId , flag , "Flag" , "nhsuk-tag--white" ) ;
204205 }
205- flagIds . Append ( flagId ) ;
206+ flagIds . Add ( flagId ) ;
206207 }
207- if ( flagIds . Any ( ) ) {
208- frameworkService . UpdateCompetencyFlags ( frameworkId , newCompetencyId , flagIds ) ;
208+ if ( flagIds . Count > 0 ) {
209+ frameworkService . UpdateCompetencyFlags ( frameworkId , newCompetencyId , [ .. flagIds ] ) ;
210+ if ( competencyRow . RowStatus == RowStatus . Skipped )
211+ {
212+ competencyRow . RowStatus = RowStatus . CompetencyUpdated ;
213+ }
209214 }
210215 }
211216
0 commit comments