Example #1
0
        public override BUSDataMapField Init(TContext context)
        {
            BUSDataMapField        businessEntity   = base.Init(context);
            DataMapObjectComponent dataMapComponent = context.DataMapObjectComponents
                                                      .AsNoTracking()
                                                      .Select(mapComponent => new
            {
                id = mapComponent.Id,
                sourceBOComponentId      = mapComponent.SourceBOComponentId,
                destinationBOComponentId = mapComponent.DestinationBOComponentId
            })
                                                      .Select(mapComponent => new DataMapObjectComponent
            {
                Id = mapComponent.id,
                SourceBOComponentId      = mapComponent.sourceBOComponentId,
                DestinationBOComponentId = mapComponent.destinationBOComponentId,
            })
                                                      .FirstOrDefault(i => i.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Data Map Object Component"));

            if (dataMapComponent != null)
            {
                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;
            }
            return(businessEntity);
        }
        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);
        }
Example #3
0
        public override DataMapObjectComponent BusinessToData(DataMapObjectComponent dataMapComponent, BUSDataMapObjectComponent businessEntity, TContext context, bool NewRecord)
        {
            DataMapObjectComponent dataEntity = base.BusinessToData(dataMapComponent, businessEntity, context, NewRecord);

            dataEntity.DataMapObject             = businessEntity.DataMapObject;
            dataEntity.DataMapObjectId           = businessEntity.DataMapObjectId;
            dataEntity.SourceBOComponent         = businessEntity.SourceBOComponent;
            dataEntity.SourceBOComponentId       = businessEntity.SourceBOComponentId;
            dataEntity.DestinationBOComponent    = businessEntity.DestinationBOComponent;
            dataEntity.DestinationBOComponentId  = businessEntity.DestinationBOComponentId;
            dataEntity.SourceSearchSpecification = businessEntity.SourceSearchSpecification;
            dataEntity.ParentDataMapComponentId  = businessEntity.ParentDataMapComponentId;
            return(dataEntity);
        }
        public override BUSDataMapObjectComponent UIToBusiness(UIDataMapObjectComponent UIEntity, TContext context, IViewInfo viewInfo, bool isNewRecord)
        {
            BUSDataMapObjectComponent businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, isNewRecord);
            DataMapObject             dataMapObject  = context.DataMapObjects
                                                       .AsNoTracking()
                                                       .Select(mapObject => new
            {
                id   = mapObject.Id,
                name = mapObject.Name,
                sourceBusinessObjectId      = mapObject.SourceBusinessObjectId,
                destinationBusinessObjectId = mapObject.DestinationBusinessObjectId,
                dataMapComponents           = mapObject.DataMapObjectComponents.Select(mapComponent => new
                {
                    id   = mapComponent.Id,
                    name = mapComponent.Name
                })
            })
                                                       .Select(mapObject => new DataMapObject
            {
                Id   = mapObject.id,
                Name = mapObject.name,
                SourceBusinessObjectId      = mapObject.sourceBusinessObjectId,
                DestinationBusinessObjectId = mapObject.destinationBusinessObjectId,
                DataMapObjectComponents     = mapObject.dataMapComponents.Select(mapComponent => new DataMapObjectComponent
                {
                    Id   = mapComponent.id,
                    Name = mapComponent.name
                }).ToList()
            })
                                                       .FirstOrDefault(i => i.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Data Map Object"));

            if (dataMapObject == null)
            {
                businessEntity.ErrorMessage = "First you need create data map object.";
            }
            else
            {
                DataMapObjectComponent mapObjectComponent = dataMapObject?.DataMapObjectComponents.FirstOrDefault(n => n.Name == UIEntity.Name);
                if (dataMapObject?.SourceBusinessObjectId == Guid.Empty)
                {
                    businessEntity.ErrorMessage = $"At first you need to add a source business object to data map object {dataMapObject.Name}.";
                }
                if (dataMapObject?.DestinationBusinessObjectId == Guid.Empty)
                {
                    businessEntity.ErrorMessage = $"At first you need to add a destination business object to data map object {dataMapObject.Name}.";
                }
                else if (mapObjectComponent != null && mapObjectComponent.Id != UIEntity.Id)
                {
                    businessEntity.ErrorMessage = $"Data map component with this name is already exists in data map object {dataMapObject.Name}.";
                }
                else
                {
                    businessEntity.DataMapObject   = dataMapObject;
                    businessEntity.DataMapObjectId = dataMapObject.Id;

                    // SourceBusinessObject
                    BusinessObject sourceBusinessObject = context.BusinessObjects
                                                          .AsNoTracking()
                                                          .Select(bo => new
                    {
                        id = bo.Id,
                        busObjectComponents = bo.BusObjectComponents.Select(boc => new
                        {
                            id      = boc.Id,
                            name    = boc.Name,
                            busComp = new
                            {
                                id   = boc.BusComp.Id,
                                name = boc.BusComp.Name
                            }
                        })
                    })
                                                          .Select(bo => new BusinessObject
                    {
                        Id = bo.id,
                        BusObjectComponents = bo.busObjectComponents.Select(boc => new BusinessObjectComponent
                        {
                            Id      = boc.id,
                            Name    = boc.name,
                            BusComp = new BusinessComponent
                            {
                                Id   = boc.busComp.id,
                                Name = boc.busComp.name
                            }
                        }).ToList()
                    })
                                                          .FirstOrDefault(i => i.Id == dataMapObject.SourceBusinessObjectId);
                    if (sourceBusinessObject != null)
                    {
                        businessEntity.SourceBusinessObject   = sourceBusinessObject;
                        businessEntity.SourceBusinessObjectId = sourceBusinessObject.Id;

                        // SourceBusinessComponent
                        BusinessObjectComponent sourceBOComponent = sourceBusinessObject.BusObjectComponents.FirstOrDefault(n => n.BusComp.Name == UIEntity.SourceBOComponentName);
                        if (sourceBOComponent != null)
                        {
                            businessEntity.SourceBOComponent     = sourceBOComponent;
                            businessEntity.SourceBOComponentId   = sourceBOComponent.Id;
                            businessEntity.SourceBOComponentName = sourceBOComponent.Name;
                            BusinessComponent sourceBusinessComponent = context.BusinessComponents.FirstOrDefault(i => i.Id == sourceBOComponent.BusComp.Id);
                            businessEntity.SourceBusinessComponent   = sourceBusinessComponent;
                            businessEntity.SourceBusinessComponentId = sourceBusinessComponent.Id;
                        }
                    }

                    // DestinationBusinessObject
                    BusinessObject destinationBusinessObject = context.BusinessObjects
                                                               .AsNoTracking()
                                                               .Select(bo => new
                    {
                        id = bo.Id,
                        busObjectComponents = bo.BusObjectComponents.Select(boc => new
                        {
                            id      = boc.Id,
                            name    = boc.Name,
                            busComp = new
                            {
                                id   = boc.BusComp.Id,
                                name = boc.BusComp.Name
                            }
                        })
                    })
                                                               .Select(bo => new BusinessObject
                    {
                        Id = bo.id,
                        BusObjectComponents = bo.busObjectComponents.Select(boc => new BusinessObjectComponent
                        {
                            Id      = boc.id,
                            Name    = boc.name,
                            BusComp = new BusinessComponent
                            {
                                Id   = boc.busComp.id,
                                Name = boc.busComp.name
                            }
                        }).ToList()
                    })
                                                               .FirstOrDefault(i => i.Id == dataMapObject.DestinationBusinessObjectId);
                    if (destinationBusinessObject != null)
                    {
                        businessEntity.DestinationBusinessObject   = destinationBusinessObject;
                        businessEntity.DestinationBusinessObjectId = destinationBusinessObject.Id;

                        // DestinationBusinessComponent
                        BusinessObjectComponent destinationBOComponent = destinationBusinessObject.BusObjectComponents.FirstOrDefault(n => n.BusComp.Name == UIEntity.DestinationBOComponentName);
                        if (destinationBOComponent != null)
                        {
                            businessEntity.DestinationBOComponent     = destinationBOComponent;
                            businessEntity.DestinationBOComponentId   = destinationBOComponent.Id;
                            businessEntity.DestinationBOComponentName = destinationBOComponent.Name;
                            BusinessComponent destinationBusinessComponent = context.BusinessComponents.FirstOrDefault(i => i.Id == destinationBOComponent.BusComp.Id);
                            businessEntity.DestinationBusinessComponent   = destinationBusinessComponent;
                            businessEntity.DestinationBusinessComponentId = destinationBusinessComponent.Id;
                        }
                    }

                    // ParentDataMapComponent
                    DataMapObjectComponent parentDataMapComponent = dataMapObject.DataMapObjectComponents.FirstOrDefault(n => n.Name == UIEntity.ParentDataMapComponentName);
                    if (parentDataMapComponent != null)
                    {
                        businessEntity.ParentDataMapComponent     = parentDataMapComponent;
                        businessEntity.ParentDataMapComponentId   = parentDataMapComponent.Id;
                        businessEntity.ParentDataMapComponentName = parentDataMapComponent.Name;
                    }
                    businessEntity.SourceSearchSpecification = UIEntity.SourceSearchSpecification;
                }
            }
            return(businessEntity);
        }
Example #5
0
        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);
        }
Example #6
0
        public override BUSDataMapObjectComponent DataToBusiness(DataMapObjectComponent dataEntity, TContext context)
        {
            BUSDataMapObjectComponent businessEntity = base.DataToBusiness(dataEntity, context);
            DataMapObject             dataMapObject  = context.DataMapObjects
                                                       .AsNoTracking()
                                                       .Select(mapObject => new
            {
                id   = mapObject.Id,
                name = mapObject.Name,
                sourceBusinessObjectId      = mapObject.SourceBusinessObjectId,
                destinationBusinessObjectId = mapObject.DestinationBusinessObjectId,
                dataMapComponents           = mapObject.DataMapObjectComponents.Select(mapComponent => new
                {
                    id   = mapComponent.Id,
                    name = mapComponent.Name
                })
            })
                                                       .Select(mapObject => new DataMapObject
            {
                Id   = mapObject.id,
                Name = mapObject.name,
                SourceBusinessObjectId      = mapObject.sourceBusinessObjectId,
                DestinationBusinessObjectId = mapObject.destinationBusinessObjectId,
                DataMapObjectComponents     = mapObject.dataMapComponents.Select(mapComponent => new DataMapObjectComponent
                {
                    Id   = mapComponent.id,
                    Name = mapComponent.name
                }).ToList()
            })
                                                       .FirstOrDefault(i => i.Id == dataEntity.DataMapObjectId);

            businessEntity.DataMapObject   = dataMapObject;
            businessEntity.DataMapObjectId = dataMapObject.Id;

            // SourceBusinessObject
            BusinessObject sourceBusinessObject = context.BusinessObjects
                                                  .Select(bo => new
            {
                id = bo.Id,
                busObjectComponents = bo.BusObjectComponents.Select(boc => new
                {
                    id        = boc.Id,
                    busCompId = boc.BusCompId,
                    name      = boc.Name
                })
            })
                                                  .Select(bo => new BusinessObject
            {
                Id = bo.id,
                BusObjectComponents = bo.busObjectComponents.Select(boc => new BusinessObjectComponent
                {
                    Id        = boc.id,
                    BusCompId = boc.busCompId,
                    Name      = boc.name
                }).ToList()
            })
                                                  .FirstOrDefault(i => i.Id == dataMapObject.SourceBusinessObjectId);

            if (sourceBusinessObject != null)
            {
                businessEntity.SourceBusinessObject   = sourceBusinessObject;
                businessEntity.SourceBusinessObjectId = sourceBusinessObject.Id;
            }

            // SourceBusinessComponent
            BusinessObjectComponent sourceBOComponent = sourceBusinessObject.BusObjectComponents.FirstOrDefault(i => i.Id == dataEntity.SourceBOComponentId);

            if (sourceBOComponent != null)
            {
                businessEntity.SourceBOComponent     = sourceBOComponent;
                businessEntity.SourceBOComponentId   = sourceBOComponent.Id;
                businessEntity.SourceBOComponentName = sourceBOComponent.Name;
                BusinessComponent sourceBusinessComponent = context.BusinessComponents.FirstOrDefault(i => i.Id == sourceBOComponent.BusCompId);
                businessEntity.SourceBusinessComponent   = sourceBusinessComponent;
                businessEntity.SourceBusinessComponentId = sourceBusinessComponent.Id;
            }

            // DestinationBusinessObject
            BusinessObject destinationBusinessObject = context.BusinessObjects
                                                       .Select(bo => new
            {
                id = bo.Id,
                busObjectComponents = bo.BusObjectComponents.Select(boc => new
                {
                    id        = boc.Id,
                    busCompId = boc.BusCompId,
                    name      = boc.Name
                })
            })
                                                       .Select(bo => new BusinessObject
            {
                Id = bo.id,
                BusObjectComponents = bo.busObjectComponents.Select(boc => new BusinessObjectComponent
                {
                    Id        = boc.id,
                    BusCompId = boc.busCompId,
                    Name      = boc.name
                }).ToList()
            })
                                                       .FirstOrDefault(i => i.Id == dataMapObject.DestinationBusinessObjectId);

            if (destinationBusinessObject != null)
            {
                businessEntity.DestinationBusinessObject   = destinationBusinessObject;
                businessEntity.DestinationBusinessObjectId = destinationBusinessObject.Id;
            }

            // DestinationBusinessComponent
            BusinessObjectComponent destinationBOComponent = destinationBusinessObject.BusObjectComponents.FirstOrDefault(i => i.Id == dataEntity.DestinationBOComponentId);

            if (destinationBOComponent != null)
            {
                businessEntity.DestinationBOComponent     = destinationBOComponent;
                businessEntity.DestinationBOComponentId   = destinationBOComponent.Id;
                businessEntity.DestinationBOComponentName = destinationBOComponent.Name;
                BusinessComponent destinationBusinessComponent = context.BusinessComponents.FirstOrDefault(i => i.Id == destinationBOComponent.BusCompId);
                businessEntity.DestinationBusinessComponent   = destinationBusinessComponent;
                businessEntity.DestinationBusinessComponentId = destinationBusinessComponent.Id;
            }

            // ParentDataMapComponent
            DataMapObjectComponent parentDataMapComponent = dataMapObject.DataMapObjectComponents.FirstOrDefault(i => i.Id == dataEntity.ParentDataMapComponentId);

            if (parentDataMapComponent != null)
            {
                businessEntity.ParentDataMapComponent     = parentDataMapComponent;
                businessEntity.ParentDataMapComponentId   = parentDataMapComponent.Id;
                businessEntity.ParentDataMapComponentName = parentDataMapComponent.Name;
            }

            businessEntity.SourceSearchSpecification = dataEntity.SourceSearchSpecification;
            return(businessEntity);
        }