示例#1
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            if (DeviceToken.IsNullOrEmpty() || UserId == 0)
            {
                //yield return new ValidationResult("设备编号与用户编号为必传!", new string[] { "UserId", "DeviceToken" });
                yield return(new ValidationResult("服务器开小差啦,请重试!"));
            }

            if (UserId == 0 && !DeviceToken.IsNullOrEmpty() && DeviceToken.Length < 10)
            {
                yield return(new ValidationResult("服务器开小差啦,请重试!"));
            }
        }
示例#2
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            if (DeviceToken.IsNullOrEmpty() && (!UserId.HasValue || UserId.Value <= 0))
            {
                yield return(new ValidationResult("必须传设备编号与用户编号之一!", new string[] { "UserId" }));
            }

            if (!UserId.HasValue)
            {
                if ((DeviceToken ?? string.Empty).Length < 10)
                {
                    yield return(new ValidationResult("设备标识格式不正确!", new string[] { "DeviceToken" }));
                }
            }
        }