protected virtual bool VerifyPackageRules(RegulatorXmlObjectCollectionPackage <RegulatorFacilitySubmittalPacket> package) { bool result = true; //this method verifies that the SubmittedOn value for each facility submittal and submittal element is unique for that submittal element and facility (CERSID). //its also meant to verify other data submitted through XML. This verifies the data deserialized from XML before it //goes through the main business logic validations sequence. foreach (var rfsPacket in package.Packets) { foreach (var fsePacket in rfsPacket.FacilitySubmittalElementPackets) { if (Repository.FacilitySubmittalElements.IsDuplicate(fsePacket.FacilitySubmittalElement)) { TransactionScope.WriteMessage("Submittal already exists for " + ((SubmittalElementType)fsePacket.FacilitySubmittalElement.SubmittalElementID).ToString() + " for CERSID " + fsePacket.FacilitySubmittalElement.CERSID + " with submittedOn value (" + fsePacket.FacilitySubmittalElement.SubmittedDateTime.Value.ToString() + ").", EDTTransactionMessageType.Error); result = false; } } } return(result); }
protected virtual bool ValidateCommitPackage(RegulatorXmlObjectCollectionPackage <RegulatorFacilitySubmittalPacket> package) { if (package == null) { throw new ArgumentException("package"); } bool result = false; foreach (var fsPacket in package.Packets) { ValidateCommitPackage(fsPacket); } //see if we have any invalid FacilitySubmittal Packets int invalidCount = package.Packets.Where(p => !p.IsValid).Count(); //if not, we are good to go to officially say we are ok with this package and flip all the voided to false and update metadata. if (invalidCount == 0) { result = true; //now we need to go through and trigger all the updates to flip the voided flag on everything. foreach (var fsPacket in package.Packets) { //change voided to false for each and every FacilitySubmittalElement. foreach (var fsePacket in fsPacket.FacilitySubmittalElementPackets) { if (fsePacket.Type == SubmittalElementType.FacilityInformation) { //process additional business rules information. PostProcessFacilityInformationSubmittalElementBusinessLogic(fsePacket.FacilitySubmittalElement); //If the Facility Information FSE has a Status of "Accepted", call Business Service method to update Facility from Facility Information FSE. //This ensures that any changes to important Facility data such as Name, Address, FacilityID, EPAID, etc. that are accepted by the Regulator //get propegated to the Facility table if (fsePacket.FacilitySubmittalElement.StatusID == (int)SubmittalElementStatus.Accepted) { ServiceManager.BusinessLogic.SubmittalElements.FacilityInformation.UpdateFacilityFromFacilityInformation(fsePacket.FacilitySubmittalElement); } } //update voided for FSE and save. fsePacket.FacilitySubmittalElement.Voided = false; //save this submittal element. Repository.FacilitySubmittalElements.Save(fsePacket.FacilitySubmittalElement); TransactionScope.Connect(fsePacket.FacilitySubmittalElement); //update FRSE metadata. ProcessFacilityRegulatorSubmittalElementMetadata(fsPacket.Facility, fsePacket); UpdateFacilityRegulatorSubmittalElement(fsPacket.Facility, fsePacket); } //if we got a FacilitySubmittal lets update it's voided to false as well and update it. if (fsPacket.FacilitySubmittal != null) { fsPacket.FacilitySubmittal.Voided = false; Repository.FacilitySubmittals.Save(fsPacket.FacilitySubmittal); } ServiceManager.Events.CreateFacilitySubmittalNotification(fsPacket.Facility, fsPacket.FacilitySubmittal); TransactionScope.Connect(fsPacket.FacilitySubmittal); } } return(result); }