public RigChecklistValidationResult ValidateAuditProtocols(int auditId)
        {
            RigChecklistValidationResult validationResult = new RigChecklistValidationResult();
            var audit = Repository.Get(auditId);

            // var notValid = false;

            if (audit == null)
            {
                validationResult.AddError("Audit not found");
                return(validationResult);
            }
            foreach (var ap in audit.OapAuditProtocols)
            {
                if (ap.RigOapChecklist?.OapChecklist?.OapType?.Code == "AR")
                {
                    var checklist = ap.RigOapChecklist;

                    if (checklist.Assessors.Count(a => a.IsLead) == 0)
                    {
                        validationResult.AddError("There must be at least one lead assessor");
                        // notValid = true;
                    }
                    if (checklist.Questions.Any(q => q.Answers.Any(a => string.IsNullOrEmpty(a.Value))))
                    {
                        validationResult.AddError("All checklists questions must be answered");

                        return(validationResult);
                    }
                }
            }
            return(validationResult);
            //  ValidateAuditAnswers(audit, validationResult);
        }
Beispiel #2
0
 private void ValidateChecklistAnswers(RigOapChecklist checklist, RigChecklistValidationResult validationResult)
 {
     if (checklist.Questions.Any(q => q.Answers.Any(a => string.IsNullOrEmpty(a.Value))))
     {
         validationResult.AddError("All checklist questions must be answered");
     }
 }
 private void ValidateAuditAnswers(OapAudit audit, RigChecklistValidationResult validationResult)
 {
     // if (checklist.Questions.Any(q => q.Answers.Any(a => string.IsNullOrEmpty(a.Value))))
     foreach (var ap in audit.OapAuditProtocols)
     {
         var checklist = ap.RigOapChecklist;
         if (checklist.Assessors.Count(a => a.IsLead) == 0)
         {
             validationResult.AddError("There must be at least one lead assessor");
         }
         if (checklist.Questions.Any(q => q.Answers.Any(a => string.IsNullOrEmpty(a.Value))))
         {
             validationResult.AddError("All checklist questions must be answered");
         }
     }
 }
Beispiel #4
0
 private void ValidateChecklistPlanning(RigOapChecklist checklist, RigChecklistValidationResult validationResult)
 {
     if (checklist.LocationId == 0)
     {
         validationResult.AddError("Location cannot be empty");
     }
     if (checklist.ChecklistDateTime == DateTime.MinValue)
     {
         validationResult.AddError("Date cannot be empty");
     }
     if (string.IsNullOrEmpty(checklist.Title))
     {
         validationResult.AddError("Title cannot be empty");
     }
     if (checklist.Assessors.Count(a => a.IsLead) == 0)
     {
         validationResult.AddError("There must be at least one lead assessor");
     }
 }
Beispiel #5
0
        public RigChecklistValidationResult ValidateChecklist(Guid rigOapChecklistId)
        {
            RigChecklistValidationResult validationResult = new RigChecklistValidationResult();
            var checklist = Repository.Get(rigOapChecklistId);

            if (checklist == null)
            {
                validationResult.AddError("Checklist not found");
                return(validationResult);
            }

            ValidateChecklistPlanning(checklist, validationResult);
            ValidateChecklistAnswers(checklist, validationResult);

            return(validationResult);
        }