Esempio n. 1
0
        public Task BindModelAsync(ModelBindingContext bindingContext)
        {
            var model    = bindingContext.ModelName;
            var hasValue = false;

            if (!bindingContext.TryGetMigrationKind($"{model}", ref hasValue, out var value))
            {
                return(Task.CompletedTask);
            }

            if (!bindingContext.TryGetMigrationKind($"{model}.eq", ref hasValue, out var eq))
            {
                return(Task.CompletedTask);
            }

            if (!bindingContext.TryGetMigrationKind($"{model}.ne", ref hasValue, out var ne))
            {
                return(Task.CompletedTask);
            }

            if (!bindingContext.TryGetMigrationKindList($"{model}.in", ref hasValue, out var @in))
            {
                return(Task.CompletedTask);
            }

            if (!bindingContext.TryGetMigrationKindList($"{model}.ni", ref hasValue, out var ni))
            {
                return(Task.CompletedTask);
            }

            if (!hasValue)
            {
                bindingContext.Result = ModelBindingResult.Success(null);
                return(Task.CompletedTask);
            }

            bindingContext.Result = ModelBindingResult.Success(new MigrationKindParameter
            {
                Eq = value ?? eq,
                Ne = ne,
                In = @in,
                Ni = ni
            });

            return(Task.CompletedTask);
        }