Exemple #1
0
        public override UIJoin BusinessToUI(BUSJoin businessEntity)
        {
            UIJoin UIEntity = base.BusinessToUI(businessEntity);

            UIEntity.TableName = businessEntity.TableName;
            return(UIEntity);
        }
Exemple #2
0
        public override BUSJoin UIToBusiness(UIJoin UIEntity, TContext context, IViewInfo viewInfo, bool isNewRecord)
        {
            BUSJoin           businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, isNewRecord);
            BusinessComponent busComp        = context.BusinessComponents
                                               .AsNoTracking()
                                               .Select(bc => new
            {
                id    = bc.Id,
                name  = bc.Name,
                joins = bc.Joins.Select(join => new
                {
                    id   = join.Id,
                    name = join.Name
                })
            })
                                               .Select(bc => new BusinessComponent
            {
                Id    = bc.id,
                Name  = bc.name,
                Joins = bc.joins.Select(join => new Join
                {
                    Id   = join.id,
                    Name = join.name
                }).ToList()
            })
                                               .FirstOrDefault(i => i.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Business Component"));

            if (busComp == null)
            {
                businessEntity.ErrorMessage = "First you need create business component.";
            }
            else
            {
                // Если запись новая и она не уникальна, записывается ошибка
                Join join = busComp.Joins?.FirstOrDefault(n => n.Name == UIEntity.Name);
                if (join != null && join.Id != UIEntity.Id)
                {
                    businessEntity.ErrorMessage = $"Join with this name is already exists in business component {busComp.Name}.";
                }
                else
                {
                    // BusComp
                    businessEntity.BusComp   = busComp;
                    businessEntity.BusCompId = busComp.Id;

                    // Table
                    Table table = context.Tables.AsNoTracking().FirstOrDefault(n => n.Name == UIEntity.TableName);
                    if (table != null)
                    {
                        businessEntity.Table     = table;
                        businessEntity.TableId   = table.Id;
                        businessEntity.TableName = table.Name;
                    }
                }
            }
            return(businessEntity);
        }
Exemple #3
0
        public override Join BusinessToData(Join join, BUSJoin businessEntity, TContext context, bool NewRecord)
        {
            Join dataEntity = base.BusinessToData(join, businessEntity, context, NewRecord);

            // BusComp
            dataEntity.BusComp   = businessEntity.BusComp;
            dataEntity.BusCompId = businessEntity.BusCompId;

            // Table
            dataEntity.Table   = businessEntity.Table;
            dataEntity.TableId = businessEntity.TableId;
            return(dataEntity);
        }
Exemple #4
0
        public override BUSJoin DataToBusiness(Join dataEntity, TContext context)
        {
            BUSJoin businessEntity = base.DataToBusiness(dataEntity, context);

            // BusComp
            businessEntity.BusComp   = dataEntity.BusComp;
            businessEntity.BusCompId = dataEntity.BusCompId;

            // Table
            Table table = context.Tables.AsNoTracking().FirstOrDefault(i => i.Id == dataEntity.TableId);

            if (table != null)
            {
                businessEntity.Table     = table;
                businessEntity.TableId   = table.Id;
                businessEntity.TableName = table.Name;
            }
            return(businessEntity);
        }
Exemple #5
0
        public override IEnumerable <ValidationResult> BUSUIValidate(TContext context, BUSJoin businessComponent, UIJoin UIEntity)
        {
            List <ValidationResult> result = base.BUSUIValidate(context, businessComponent, UIEntity).ToList();

            if ((string.IsNullOrWhiteSpace(businessComponent.ErrorMessage)))
            {
                if (businessComponent.Table == null)
                {
                    result.Add(new ValidationResult(
                                   "Table with this name not found.",
                                   new List <string>()
                    {
                        "TableName"
                    }));
                }
            }
            return(result);
        }