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

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

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

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

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

            bindingContext.Result = ModelBindingResult.Success(new SortParameter
            {
                Asc  = value ?? asc,
                Desc = desc
            });

            return(Task.CompletedTask);
        }
Exemplo n.º 2
0
        public Task BindModelAsync(ModelBindingContext bindingContext)
        {
            var model    = bindingContext.ModelName;
            var hasValue = false;

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

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

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

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

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

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

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

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

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

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

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

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

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

            bindingContext.Result = ModelBindingResult.Success(new Int32ExParameter
            {
                Eq   = value ?? eq,
                Ne   = ne,
                Gt   = gt,
                Ge   = ge,
                Lt   = lt,
                Le   = le,
                In   = @in,
                Ni   = ni,
                Eqx  = eqx,
                Nex  = nex,
                Null = isNull
            });

            return(Task.CompletedTask);
        }
Exemplo n.º 3
0
        public async Task BindModelAsync(ModelBindingContext bindingContext)
        {
            var model    = bindingContext.ModelName;
            var hasValue = false;

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

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

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

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

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

            if (!bindingContext.TryGetString($"{model}.eqx", ref hasValue, out var eqx))
            {
                return;
            }

            if (!bindingContext.TryGetString($"{model}.nex", ref hasValue, out var nex))
            {
                return;
            }

            if (!bindingContext.TryGetBool($"{model}.null", ref hasValue, out var isNull))
            {
                return;
            }

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

            int?       _eq     = null;
            int?       _ne     = null;
            List <int> _listIn = null;
            List <int> _listNi = null;

            if ((value ?? eq) != null)
            {
                _eq = (await Accounts.GetAsync(value ?? eq))?.Id ?? -1;
            }

            if (ne != null)
            {
                _ne = (await Accounts.GetAsync(ne))?.Id ?? -1;
            }

            if (@in != null)
            {
                _listIn = new List <int>(@in.Count);
                foreach (var addr in @in)
                {
                    var acc = await Accounts.GetAsync(addr);

                    if (acc != null)
                    {
                        _listIn.Add(acc.Id);
                    }
                }
            }

            if (ni != null)
            {
                _listNi = new List <int>(ni.Count);
                foreach (var addr in ni)
                {
                    var acc = await Accounts.GetAsync(addr);

                    if (acc != null)
                    {
                        _listNi.Add(acc.Id);
                    }
                }
            }

            bindingContext.Result = ModelBindingResult.Success(new AccountParameter
            {
                Eq   = _eq,
                Ne   = _ne,
                In   = _listIn,
                Ni   = _listNi,
                Eqx  = eqx,
                Nex  = nex,
                Null = isNull
            });
        }
Exemplo n.º 4
0
        public Task BindModelAsync(ModelBindingContext bindingContext)
        {
            var model    = bindingContext.ModelName;
            var hasValue = false;

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

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

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

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

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

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

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

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

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

            bindingContext.Result = ModelBindingResult.Success(new StringParameter
            {
                Eq = value ?? eq,
                Ne = ne,
                As = @as?
                     .Replace("%", "\\%")
                     .Replace("\\*", "ъуъ")
                     .Replace("*", "%")
                     .Replace("ъуъ", "*"),
                Un = un?
                     .Replace("%", "\\%")
                     .Replace("\\*", "ъуъ")
                     .Replace("*", "%")
                     .Replace("ъуъ", "*"),
                In   = @in,
                Ni   = ni,
                Null = isNull
            });

            return(Task.CompletedTask);
        }