//return true если есть ошибки public bool ErrorsFromModelState(ModelStateDictionary modelState) { if (modelState.IsValid) { return(false); } //var errors = modelState.ToList(); //if (errors.Count == 0) //{ // return false; //} foreach (var keyInput in modelState.Keys) { var input = modelState[keyInput]; if (input.Errors.Count == 0) { continue; } var errObj = new OneError(keyInput, input.Errors.Select(x => x.ErrorMessage).ToList()); _errorService.AddError(errObj); } return(_errorService.HasError()); }
public void AddError(OneError error) { if (error != null && !string.IsNullOrWhiteSpace(error.Key)) { if (_errors.ContainsKey(error.Key)) { _errors[error.Key].Errors.AddRange(error.Errors); } else { _errors.TryAdd(error.Key, error); } } }
public void AddError(string key, string body) { if (string.IsNullOrWhiteSpace(key)) { return; } if (_errors.ContainsKey(key)) { _errors[key].Errors.Add(body); } else { var error = new OneError(key, body); _errors.TryAdd(error.Key, error); } }
/// <summary> /// Initializes a new instance of the <see cref="OneValidationException"/>. /// </summary> public OneValidationException(OneError error) : base(error) { }
public OneErrorReturn(OneError obj) { Key = obj?.Key; Errors = obj?.Errors; }
public OneMessageException(OneError error) : base(error) { }
/// <summary> /// Initializes a new instance of the <see cref="OneObjectException"/>. /// </summary> public OneObjectException(OneError error) : base(error) { }
/// <summary> /// Initializes a new instance of the <see cref="OneConnectionException"/>. /// </summary> public OneConnectionException(OneError error) : base(error) { }
/// <summary> /// Initializes a new instance of the <see cref="OneArrayException"/>. /// </summary> public OneArrayException(OneError error) : base(error) { }
protected OneException(OneError error) : base("The SDK returned error: " + error) { _error = error; }
/// <summary> /// Initializes a new instance of the <see cref="OneSocketException"/>. /// </summary> public OneSocketException(OneError error) : base(error) { }
/// <summary> /// Initializes a new instance of the <see cref="OneCodecException"/>. /// </summary> public OneCodecException(OneError error) : base(error) { }
/// <summary> /// Initializes a new instance of the <see cref="OnePayloadException"/>. /// </summary> public OnePayloadException(OneError error) : base(error) { }
/// <summary> /// Initializes a new instance of the <see cref="OneServerException"/>. /// </summary> public OneServerException(OneError error) : base(error) { }
/// <summary> /// Initializes a new instance of the <see cref="OneClientException"/>. /// </summary> public OneClientException(OneError error) : base(error) { }