Example #1
0
        public static PayResult <T> Failed(params PayError[] errors)
        {
            var result = new PayResult <T> {
                Succeeded = false
            };

            if (errors != null)
            {
                result._errors.AddRange(errors);
            }
            return(result);
        }
Example #2
0
        public static PayResult <T> Invoke(T result, PayError[] errors = null)
        {
            var r = new PayResult <T>
            {
                Succeeded = result != null,
                Result    = result
            };

            if (result == null)
            {
                r._errors.Add(new PayError
                {
                    Code        = $"{typeof(T)}",
                    Description = $"Could not find {typeof(T)} in the current context!"
                });
            }
            if (errors != null)
            {
                r._errors.AddRange(errors);
            }
            return(r);
        }