public override DataMapField BusinessToData(DataMapField dataMapField, BUSDataMapField businessEntity, TContext context, bool NewRecord) { DataMapField dataEntity = base.BusinessToData(dataMapField, businessEntity, context, NewRecord); dataEntity.DataMapObjectComponent = businessEntity.DataMapComponent; dataEntity.DataMapComponentId = businessEntity.DataMapComponentId; dataEntity.SourceField = businessEntity.SourceField; dataEntity.SourceFieldId = businessEntity.SourceFieldId; dataEntity.Destination = businessEntity.Destination; dataEntity.FieldValidation = businessEntity.FieldValidation; return(dataEntity); }
public override BUSDataMapField DataToBusiness(DataMapField dataEntity, TContext context) { BUSDataMapField businessEntity = base.DataToBusiness(dataEntity, context);; DataMapObjectComponent dataMapComponent = context.DataMapObjectComponents .AsNoTracking() .Select(mapComponent => new { id = mapComponent.Id, name = mapComponent.Name, sourceBusinessComponentId = mapComponent.SourceBOComponentId, destinationBusinessComponentId = mapComponent.DestinationBOComponentId, dataMapFields = mapComponent.DataMapFields.Select(mapField => new { id = mapField.Id, name = mapField.Name }) }) .Select(mapComponent => new DataMapObjectComponent { Id = mapComponent.id, Name = mapComponent.name, SourceBOComponentId = mapComponent.sourceBusinessComponentId, DestinationBOComponentId = mapComponent.destinationBusinessComponentId, DataMapFields = mapComponent.dataMapFields.Select(mapField => new DataMapField { Id = mapField.id, Name = mapField.name }).ToList() }) .FirstOrDefault(i => i.Id == dataEntity.DataMapComponentId); businessEntity.DataMapComponent = dataMapComponent; businessEntity.DataMapComponentId = dataMapComponent.Id; BusinessObjectComponent sourceBOComponent = context.BusinessObjectComponents.FirstOrDefault(i => i.Id == dataMapComponent.SourceBOComponentId); businessEntity.SourceBusinessComponentId = sourceBOComponent.BusCompId; BusinessObjectComponent destinationBOComponentId = context.BusinessObjectComponents.FirstOrDefault(i => i.Id == dataMapComponent.DestinationBOComponentId); businessEntity.DestinationBusinessComponentId = destinationBOComponentId.BusCompId; Field sourceField = context.Fields.FirstOrDefault(i => i.Id == dataEntity.SourceFieldId); if (sourceField != null) { businessEntity.SourceField = sourceField; businessEntity.SourceFieldId = sourceField.Id; businessEntity.SourceFieldName = sourceField.Name; } businessEntity.Destination = dataEntity.Destination; businessEntity.FieldValidation = dataEntity.FieldValidation; return(businessEntity); }
public override BUSDataMapField UIToBusiness(UIDataMapField UIEntity, TContext context, IViewInfo viewInfo, bool isNewRecord) { BUSDataMapField businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, isNewRecord); DataMapObjectComponent dataMapComponent = context.DataMapObjectComponents .AsNoTracking() .Select(mapComponent => new { id = mapComponent.Id, name = mapComponent.Name, sourceBOComponentId = mapComponent.SourceBOComponentId, destinationBOComponentId = mapComponent.DestinationBOComponentId, dataMapFields = mapComponent.DataMapFields.Select(mapField => new { id = mapField.Id, name = mapField.Name }) }) .Select(mapComponent => new DataMapObjectComponent { Id = mapComponent.id, Name = mapComponent.name, SourceBOComponentId = mapComponent.sourceBOComponentId, DestinationBOComponentId = mapComponent.destinationBOComponentId, DataMapFields = mapComponent.dataMapFields.Select(mapField => new DataMapField { Id = mapField.id, Name = mapField.name }).ToList() }) .FirstOrDefault(i => i.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Data Map Object Component")); if (dataMapComponent == null) { businessEntity.ErrorMessage = "First you need create data map component."; } else { DataMapField dataMapField = dataMapComponent?.DataMapFields.FirstOrDefault(n => n.Name == UIEntity.Name); if (dataMapComponent?.SourceBOComponentId == Guid.Empty) { businessEntity.ErrorMessage = $"At first you need to add a source business component to data map component {dataMapComponent.Name}."; } if (dataMapComponent?.DestinationBOComponentId == Guid.Empty) { businessEntity.ErrorMessage = $"At first you need to add a destination business component to data map component {dataMapComponent.Name}."; } if (dataMapField != null && dataMapField.Id != UIEntity.Id) { businessEntity.ErrorMessage = $"Data map field with this name is already exists in data map component {dataMapComponent.Name}."; } else { businessEntity.DataMapComponent = dataMapComponent; businessEntity.DataMapComponentId = dataMapComponent.Id; BusinessObjectComponent sourceBOComponent = context.BusinessObjectComponents.FirstOrDefault(i => i.Id == dataMapComponent.SourceBOComponentId); BusinessComponent sourceBusinessComponent = context.BusinessComponents .Include(f => f.Fields) .FirstOrDefault(i => i.Id == sourceBOComponent.BusCompId); businessEntity.SourceBusinessComponentId = sourceBusinessComponent.Id; Field sourceField = sourceBusinessComponent.Fields.FirstOrDefault(n => n.Name == UIEntity.SourceFieldName); businessEntity.SourceField = sourceField; businessEntity.SourceFieldId = sourceField.Id; businessEntity.SourceFieldName = sourceField.Name; BusinessObjectComponent destinationBOComponentId = context.BusinessObjectComponents.FirstOrDefault(i => i.Id == dataMapComponent.DestinationBOComponentId); businessEntity.DestinationBusinessComponentId = destinationBOComponentId.BusCompId; businessEntity.Destination = UIEntity.Destination; businessEntity.FieldValidation = UIEntity.FieldValidation; } } return(businessEntity); }