Example #1
0
        public async void Save()
        {
            if (!CanSave)
            {
                Helper.Notify("属性信息验证失败", NotificationType.Warning);
                return;
            }

            for (int i = 0; i < Properties.Count; i++)
            {
                Properties[i].Order = i + 1;
            }

            CodePropertyInputDto[] dtos   = Properties.Select(m => m.MapTo <CodePropertyInputDto>()).ToArray();
            OperationResult        result = null;
            await _provider.ExecuteScopedWorkAsync(async provider =>
            {
                IDataContract contract = provider.GetRequiredService <IDataContract>();
                result = await contract.UpdateCodeProperties(dtos);
            });

            Helper.Notify(result);
            if (!result.Succeeded)
            {
                return;
            }
            Init();
        }
Example #2
0
        private static async Task <CodeProperty> GetOrAddProperty(IDataContract contract, Guid entityId, CodeProperty prop)
        {
            CodeProperty property = contract.CodeProperties.FirstOrDefault(m => m.EntityId == entityId && m.Name == prop.Name && m.Display == prop.Display);

            if (property != null)
            {
                return(property);
            }

            CodePropertyInputDto dto = new CodePropertyInputDto()
            {
                Name         = prop.Name,
                Display      = prop.Display,
                TypeName     = prop.TypeName,
                Updatable    = prop.Updatable,
                Sortable     = prop.Sortable,
                Filterable   = prop.Filterable,
                IsRequired   = prop.IsRequired,
                MinLength    = prop.MinLength,
                MaxLength    = prop.MaxLength,
                IsNullable   = prop.IsNullable,
                IsEnum       = prop.IsEnum,
                Listable     = prop.Listable,
                IsReadonly   = prop.IsReadonly,
                IsHide       = prop.IsHide,
                IsVirtual    = prop.IsVirtual,
                IsForeignKey = prop.IsForeignKey,
                IsNavigation = prop.IsNavigation,
                RelateEntity = prop.RelateEntity,
                DataAuthFlag = prop.DataAuthFlag,
                IsInputDto   = prop.IsInputDto,
                IsOutputDto  = prop.IsOutputDto,
                DefaultValue = prop.DefaultValue,
                IsLocked     = prop.IsLocked,
                EntityId     = entityId
            };
            await contract.UpdateCodeProperties(dto);

            property = contract.CodeProperties.First(m => m.EntityId == entityId && m.Name == prop.Name && m.Display == prop.Display);

            return(property);
        }