public static bool TryGetMigrationKind(this ModelBindingContext bindingContext, string name, ref bool hasValue, out int?result)
        {
            result = null;
            var valueObject = bindingContext.ValueProvider.GetValue(name);

            if (valueObject != ValueProviderResult.None)
            {
                bindingContext.ModelState.SetModelValue(name, valueObject);
                if (!string.IsNullOrEmpty(valueObject.FirstValue))
                {
                    if (!MigrationKinds.TryParse(valueObject.FirstValue, out var kind))
                    {
                        bindingContext.ModelState.TryAddModelError(name, "Invalid migration kind.");
                        return(false);
                    }
                    hasValue = true;
                    result   = kind;
                }
            }

            return(true);
        }
        public static bool TryGetMigrationKindList(this ModelBindingContext bindingContext, string name, ref bool hasValue, out List <int> result)
        {
            result = null;
            var valueObject = bindingContext.ValueProvider.GetValue(name);

            if (valueObject != ValueProviderResult.None)
            {
                bindingContext.ModelState.SetModelValue(name, valueObject);
                if (!string.IsNullOrEmpty(valueObject.FirstValue))
                {
                    var rawValues = valueObject.FirstValue.Split(',', StringSplitOptions.RemoveEmptyEntries);

                    if (rawValues.Length == 0)
                    {
                        bindingContext.ModelState.TryAddModelError(name, "List should contain at least one item.");
                        return(false);
                    }

                    hasValue = true;
                    result   = new List <int>(rawValues.Length);

                    foreach (var rawValue in rawValues)
                    {
                        if (!MigrationKinds.TryParse(rawValue, out var kind))
                        {
                            bindingContext.ModelState.TryAddModelError(name, "List contains invalid migration kind.");
                            return(false);
                        }
                        hasValue = true;
                        result.Add(kind);
                    }
                }
            }

            return(true);
        }