@@ -400,7 +400,7 @@ public async Task<OperationResult> UpdateWorkflowCase(WorkflowCasesUpdateModel m
400400
401401 if ( workflowCase . SolvedBy != createdBySite . Name )
402402 {
403- await GenerateReportAndSendEmail ( site . LanguageId , site . Name . Replace ( " " , "" ) , workflowCase ) ;
403+ await GenerateReportAndSendEmail ( site . LanguageId , site . Name . Replace ( " " , "" ) , workflowCase , "" ) ;
404404 }
405405 }
406406
@@ -415,14 +415,33 @@ public async Task<OperationResult> UpdateWorkflowCase(WorkflowCasesUpdateModel m
415415 break ;
416416 case false when canceled :
417417 case false when noStatus :
418+ {
418419 if ( workflowCase . DeployedMicrotingUid != null )
419420 {
420- await core . CaseDelete ( ( int ) workflowCase . DeployedMicrotingUid ) ;
421+ await core . CaseDelete ( ( int ) workflowCase . DeployedMicrotingUid ) ;
421422 }
422423
423424 workflowCase . DeployedMicrotingUid = null ;
424425 await workflowCase . Update ( workflowPnDbContext ) ;
426+
427+
428+ await workflowCase . Update ( workflowPnDbContext ) ;
429+ Site site = await sdkDbContext . Sites . SingleOrDefaultAsync ( x =>
430+ x . Id == model . ToBeSolvedById ) ;
431+ Case _case = await
432+ sdkDbContext . Cases . SingleOrDefaultAsync ( x =>
433+ x . MicrotingCheckUid == workflowCase . CheckMicrotingUid ) ;
434+
435+ Site createdBySite = await sdkDbContext . Sites . SingleOrDefaultAsync ( x => x . Id == _case . SiteId ) ;
436+
437+ if ( workflowCase . SolvedBy != createdBySite . Name )
438+ {
439+ await GenerateReportAndSendEmail ( site . LanguageId , site . Name . Replace ( " " , "" ) , workflowCase , workflowCase . SolvedBy ) ;
440+ }
441+
442+
425443 break ;
444+ }
426445 case false when statusClosed :
427446 {
428447 Case _case = await
@@ -438,7 +457,7 @@ public async Task<OperationResult> UpdateWorkflowCase(WorkflowCasesUpdateModel m
438457
439458 if ( workflowCase . SolvedBy != createdBySite . Name )
440459 {
441- await GenerateReportAndSendEmail ( site . LanguageId , site . Name . Replace ( " " , "" ) , workflowCase ) ;
460+ await GenerateReportAndSendEmail ( site . LanguageId , site . Name . Replace ( " " , "" ) , workflowCase , workflowCase . SolvedBy ) ;
442461 }
443462 }
444463
@@ -530,10 +549,20 @@ await sdkDbContext.Folders.SingleOrDefaultAsync(x =>
530549
531550 Site site = await sdkDbContext . Sites . SingleOrDefaultAsync ( x =>
532551 x . Id == model . ToBeSolvedById ) ;
552+ Case _case = await
553+ sdkDbContext . Cases . SingleOrDefaultAsync ( x =>
554+ x . MicrotingCheckUid == workflowCase . CheckMicrotingUid ) ;
533555
534556 workflowCase . DeployedMicrotingUid =
535557 ( int ) await core . CaseCreate ( mainElement , "" , ( int ) site . MicrotingUid , folder . Id ) ;
536558 await workflowCase . Update ( workflowPnDbContext ) ;
559+ Site createdBySite = await sdkDbContext . Sites . SingleOrDefaultAsync ( x => x . Id == _case . SiteId ) ;
560+
561+ if ( workflowCase . SolvedBy != createdBySite . Name )
562+ {
563+ await GenerateReportAndSendEmail ( site . LanguageId , site . Name . Replace ( " " , "" ) , workflowCase , workflowCase . SolvedBy ) ;
564+ }
565+
537566 break ;
538567 }
539568 }
@@ -891,7 +920,7 @@ private async Task SendFileAsync(
891920 }
892921 }
893922
894- public async Task GenerateReportAndSendEmail ( int languageId , string userName , WorkflowCase workflowCase )
923+ public async Task GenerateReportAndSendEmail ( int languageId , string userName , WorkflowCase workflowCase , string solvedBy )
895924 {
896925 var emailRecipient = await _baseDbContext . EmailRecipients . SingleOrDefaultAsync ( x => x . Name . Replace ( " " , "" ) ==
897926 userName
@@ -923,7 +952,7 @@ public async Task GenerateReportAndSendEmail(int languageId, string userName, Wo
923952 . Replace ( "{{Type}}" , workflowCase . IncidentType )
924953 . Replace ( "{{Location}}" , workflowCase . IncidentPlace )
925954 . Replace ( "{{Description}}" , workflowCase . Description . Replace ( "&" , "&" ) )
926- . Replace ( "<p>Ansvarlig: {{SolvedBy}}</p>" , "" )
955+ . Replace ( "<p>Ansvarlig: {{SolvedBy}}</p>" , solvedBy )
927956 . Replace ( "<p>Handlingsplan: {{ActionPlan}}</p>" , "" ) ;
928957
929958 await SendFileAsync (
0 commit comments