protected bool AreCuttingUnitsValid(out string errorMsg) { bool allCUValid = true; errorMsg = "Unit Errors Found, "; //check has errors on all cutting units var dupUnitCodes = CuttingUnits .GroupBy(unit => unit.Code) .Where(grouping => grouping.Count() > 1) .Select(grouping => grouping.Key); if (dupUnitCodes.Count() > 0) { errorMsg += $"Duplicates in Cutting Unit Code(s): {String.Join(", ", dupUnitCodes.ToArray())}"; allCUValid = false; } foreach (CuttingUnitDO cu in CuttingUnits) { cu.Validate(); //call validate before we check for errors if (cu.HasErrors()) { allCUValid = false; //set all valid flag to false errorMsg += "\n Unit = " + cu.Code; //add unit code to error message break; //and break out of the loop } } return(allCUValid); }
//TODO make testable constructor public CruiseWizardPresenter(CruiseWizardView View, WindowPresenter windowPresenter, IApplicationController applicationController, DAL database) { this.View = View; WindowPresenter = windowPresenter; ApplicationController = applicationController; View.Presenter = this; _database = database; LoadSetupData(); //load tree defaults, product codes, etc. LoadCruiseData(); //read data from existing file //See if the file contains a template file record var templatePath = _database.ReadGlobalValue("CSM", "TemplatePath"); if (!String.IsNullOrEmpty(templatePath)) { _fileHasTemplate = true; _templateFile = new FileInfo(templatePath); View.SetTemplatePathTextBox(templatePath, false); } if (CuttingUnits.Count == 0) { CuttingUnits.Add(GetNewCuttingUnit()); } }