Example #1
0
        public static BaseMetadata CreateInstance(MetadataField field, BaseMetadata metadata, Guid?referenceCode = null)
        {
            BaseMetadata result = null;

            if (referenceCode.IsNull())
            {
                referenceCode = Guid.Empty;
            }

            switch (field.Type)
            {
            case FieldType.Store:
                result = new StoreMetadata()
                {
                    StoreCode = referenceCode.Value
                };
                break;

            case FieldType.Account:
                result = new AccountMetadata()
                {
                    AccountCode = referenceCode.Value
                };
                break;
            }

            result.Field = field;

            if (!metadata.IsNull())
            {
                result.Value = metadata.Value;
            }

            return(result);
        }
Example #2
0
        public BaseMetadata Update(BaseMetadata metadata)
        {
            this.Value      = metadata.Value;
            this.UpdateDate = DateTime.Now;

            return(this);
        }
Example #3
0
        public override bool IsValid(BaseMetadata metadata)
        {
            if (metadata.Value.IsNullorEmpty() || Values.IsNull() || Values.Count.IsZero())
            {
                return(true);
            }

            bool valid = Values.Any(v => v == metadata.Value);

            return(valid);
        }
Example #4
0
        public override bool IsValid(BaseMetadata metadata)
        {
            if (metadata.Value.IsNullorEmpty())
            {
                return(true);
            }

            var schema = JsonSchema.FromJsonAsync(Schema);

            schema.Wait();

            var errors = schema.Result.Validate(metadata.Value);

            bool valid = errors.Count == 0;

            return(valid);
        }
Example #5
0
 public abstract bool IsValid(BaseMetadata metadata);