foreach(var project in dto.ProSupplierMasterInfo.JobReferences) { Dictionary<ProTopic,…
- User
foreach(var project in dto.ProSupplierMasterInfo.JobReferences) { Dictionary<ProTopic, string[]> _requiredTopic = new Dictionary<ProTopic, string[]>() { { ActionEvent.CreateFullRegistration, [ GetNestedPropertyPath((CreateFullRegistrationDto x) => x.ProSupplierMasterInfo.JobReferences.First(a => a == project).ServiceType), GetNestedPropertyPath((CreateFullRegistrationDto x) => x.ProSupplierMasterInfo.JobReferences.First(a => a == project).ProjectValue), GetNestedPropertyPath((CreateFullRegistrationDto x) => x.ProSupplierMasterInfo.JobReferences.First(a => a == project).ClientName), GetNestedPropertyPath((CreateFullRegistrationDto x) => x.ProSupplierMasterInfo.JobReferences.First(a => a == project).ProjectDescription), GetNestedPropertyPath((CreateFullRegistrationDto x) => x.ProSupplierMasterInfo.JobReferences.First(a => a == project).ProjectStatus), GetNestedPropertyPath((CreateFullRegistrationDto x) => x.ProSupplierMasterInfo.JobReferences.First(a => a == project).CompletionDate), ]
code} }; ValidateRequiredData(topicData, _requiredTopic);}
foreach(var address in dto.ProSupplierMasterInfo.Addresses) { Dictionary<ProTopic, string[]> _requiredTopic = new Dictionary<ProTopic, string[]>() { { ActionEvent.CreateFullRegistration, [ GetNestedPropertyPath((CreateFullRegistrationDto x) => x.ProSupplierMasterInfo.Addresses.First(a => a == address).Title), GetNestedPropertyPath((CreateFullRegistrationDto x) => x.ProSupplierMasterInfo.Addresses.First(a => a == address).OfficialCapacity), GetNestedPropertyPath((CreateFullRegistrationDto x) => x.ProSupplierMasterInfo.Addresses.First(a => a == address).FirstName), ]
code} }; ValidateRequiredData(topicData, _requiredTopic);}
The above codes are similar, will loop from the list for checking the required data have value on it. Can you help me to write a reuse function to do the same thing in C#?
- Assistant