Beispiel #1
0
        public override UIBusinessComponent BusinessToUI(BUSBusinessComponent businessEntity)
        {
            UIBusinessComponent UIEntity = base.BusinessToUI(businessEntity);

            UIEntity.TableName  = businessEntity.TableName;
            UIEntity.ShadowCopy = businessEntity.ShadowCopy;
            return(UIEntity);
        }
Beispiel #2
0
        public override BUSBusinessComponent UIToBusiness(UIBusinessComponent UIEntity, TContext context, IViewInfo viewInfo, bool isNewRecord)
        {
            BUSBusinessComponent businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, isNewRecord);
            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;
            }
            else
            {
                businessEntity.Table   = null;
                businessEntity.TableId = Guid.Empty;
            }
            businessEntity.ShadowCopy = UIEntity.ShadowCopy;
            return(businessEntity);
        }
        public override void ExecuteQuery([FromBody] UIBusinessComponent model)
        {
            base.ExecuteQuery(model);
            string        searchSpecification = "";
            List <object> searchSpecArgs      = new List <object>();

            if (!string.IsNullOrWhiteSpace(model.Name))
            {
                searchSpecification += $"Name.ToLower().Contains(@0)";
                searchSpecArgs.Add(model.Name.ToLower());
            }
            if (!string.IsNullOrWhiteSpace(model.TableName))
            {
                List <Guid?> tablesId = new List <Guid?>();
                context.Tables.Where(n => n.Name.ToLower().Contains(model.TableName.ToLower())).ToList().ForEach(table => tablesId.Add(table.Id));
                searchSpecArgs.Add(tablesId);
                searchSpecification = string.IsNullOrWhiteSpace(searchSpecification) ? "@0.Contains(TableId)" : $"{searchSpecification} && @1.Contains(TableId)";
            }
            BusinessObjectComponent objectComponent = viewInfo.BOComponents.FirstOrDefault(n => n.Name == "Business Component");

            ComponentsRecordsInfo.SetSearchSpecification(objectComponent.Name, SearchSpecTypes.SearchSpecification, searchSpecification);
            ComponentsRecordsInfo.SetSearchSpecification(objectComponent.Name, SearchSpecTypes.SearchSpecArgs, searchSpecArgs.ToArray());
        }
Beispiel #4
0
        public override IEnumerable <ValidationResult> BUSUIValidate(TContext context, BUSBusinessComponent businessComponent, UIBusinessComponent UIEntity)
        {
            List <ValidationResult> result = base.BUSUIValidate(context, businessComponent, UIEntity).ToList();

            if (string.IsNullOrWhiteSpace(businessComponent.ErrorMessage))
            {
                if (businessComponent.Table == null && !string.IsNullOrWhiteSpace(UIEntity.TableName))
                {
                    result.Add(new ValidationResult("Table with this name not found.", new List <string>()
                    {
                        "TableName"
                    }));
                }
            }
            return(result);
        }
Beispiel #5
0
        public override IEnumerable <ValidationResult> UIValidate(TContext context, IViewInfo viewInfo, UIBusinessComponent UIEntity, bool isNewRecord)
        {
            List <ValidationResult> result            = base.UIValidate(context, viewInfo, UIEntity, isNewRecord).ToList();
            BusinessComponent       businessComponent = context.BusinessComponents.AsNoTracking().FirstOrDefault(n => n.Name == UIEntity.Name);

            if (businessComponent != null && businessComponent.Id != UIEntity.Id)
            {
                result.Add(new ValidationResult("Business component with this name is already exists.", new List <string>()
                {
                    "Name"
                }));
            }
            return(result);
        }