void FillFieldMappingValueTables(SystemToDbViewModel syncAllViewModel, Staging staging, Master master, SyncSystemFieldMapping fieldMapping, string customFieldValue) { StagingFieldMappingValue stagingValue = new StagingFieldMappingValue { Staging = staging, SyncSystemFieldMappingId = fieldMapping.SyncSystemFieldMappingId, Value = customFieldValue }; syncAllViewModel.StagingFieldMappingValuesToInsert.Add(stagingValue); MasterFieldMappingValue masterValue = new MasterFieldMappingValue { Master = master, SyncSystemFieldMappingId = fieldMapping.SyncSystemFieldMappingId, Value = customFieldValue }; syncAllViewModel.MasterFieldMappingValuesToInsert.Add(masterValue); }
private void SetCustomFields(SystemToDbViewModel systemToDbViewModel, SyncSystemFieldMapping fieldMapping, Master master, Staging staging, MasterHistory masterHistory, string resultValue, List <MasterFieldMappingValue> masterFieldMappingValues, bool isOnlyStaging = false) { if (fieldMapping == null) { return; } if (!isOnlyStaging) { if (master != null) { MasterFieldMappingValue masterValue = masterFieldMappingValues .FirstOrDefault(x => x.SyncSystemFieldMappingId == fieldMapping.SyncSystemFieldMappingId); if (masterValue == null) { masterValue = new MasterFieldMappingValue { Master = master, SyncSystemFieldMappingId = fieldMapping.SyncSystemFieldMappingId }; systemToDbViewModel.MasterFieldMappingValuesToInsert.Add(masterValue); } if (!String.IsNullOrEmpty(resultValue)) { masterValue.Value = resultValue.RemoveNewLinesTabs(); } } if (masterHistory != null) { MasterHistoryFieldMappingValue masterHistoryValue = new MasterHistoryFieldMappingValue { MasterHistory = masterHistory, SyncSystemFieldMappingId = fieldMapping.SyncSystemFieldMappingId, Value = resultValue }; systemToDbViewModel.MasterHistoryFieldMappingValuesToInsert.Add(masterHistoryValue); } } if (staging != null) { StagingFieldMappingValue stagingValue = new StagingFieldMappingValue { Staging = staging, SyncSystemFieldMappingId = fieldMapping.SyncSystemFieldMappingId, Value = resultValue }; systemToDbViewModel.StagingFieldMappingValuesToInsert.Add(stagingValue); } if (!String.IsNullOrEmpty(fieldMapping.StagingFieldName)) { if (staging != null) { PropertyInfo piStaging = typeof(Staging).GetProperty(fieldMapping.StagingFieldName); piStaging?.SetValue(staging, resultValue); } if (!isOnlyStaging) { PropertyInfo piMaster = typeof(Master).GetProperty(fieldMapping.StagingFieldName); piMaster?.SetValue(master, resultValue); PropertyInfo piMasterHistory = typeof(MasterHistory).GetProperty(fieldMapping.StagingFieldName); piMasterHistory?.SetValue(masterHistory, resultValue); } } }