/// <summary> /// BURO = Batch Update Review Outcomes /// </summary> /// <returns></returns> public BuroViewModel Execute(BuroViewModel vm , IUploadRepository uploadRepository , IQuestionnaireRepository questionnaireRepository , IAuditService auditService , IReviewRepository reviewRepository) { var uploadList = uploadRepository.GetAll(); foreach (var upload in uploadList) { if (upload.AcceptedFlag) { continue; // once upload is accepted its over } var uploadId = upload.UploadId; var reviewList = reviewRepository.GetAllByUploadId(uploadId); foreach (var review in reviewList) { vm.ReviewsRead++; IsDirty = false; // get the questionaire data var q = questionnaireRepository.GetReviewQuestionnaireByReviewId(review.ReviewId); if (q == null) { continue; } var oldVals = review; CheckForQuestionaireAssessmentOutcome(q, review); CheckForQuestionaireRecoveryReason(q, review); CheckForQuestionaireAssessmentAction(q, review); CheckForQuestionaireFinalOutcome(q, review); if (!IsDirty) { continue; } var errors = new List <IntegrityError>(); ApplyReviewModelValidations(review, errors); if (errors.Count > 0) { AuditErrors(auditService, errors); vm.ValidationErrors += errors.Count; } else { review.UpdatedBy = BuroUser; review.UpdatedOn = DateTime.Now; reviewRepository.Update(review); auditService.AuditActivity(UpdateMessage(review, oldVals), BuroUser); vm.ReviewsUpdated++; } } } return(vm); }