diff --git a/src/ModelResult/ModelResults/ErrorModelResult.cs b/src/ModelResult/ModelResults/ErrorModelResult.cs index eb3288f..fbd1b79 100644 --- a/src/ModelResult/ModelResults/ErrorModelResult.cs +++ b/src/ModelResult/ModelResults/ErrorModelResult.cs @@ -19,7 +19,7 @@ public ErrorModelResult(string code, string message, ErrorInfoItem[]? items = nu public ErrorInfoItem[] ErrorItems => Error.Items; - public override ModelResultType Type { get; } = ModelResultType.Error; + public override ModelResultType Type => ModelResultType.Error; } public class ErrorModelResult : ModelResult diff --git a/src/ModelResult/ModelResults/ModelResult.cs b/src/ModelResult/ModelResults/ModelResult.cs index 46fe70c..3f69da7 100644 --- a/src/ModelResult/ModelResults/ModelResult.cs +++ b/src/ModelResult/ModelResults/ModelResult.cs @@ -21,6 +21,11 @@ public ErrorModelResult AsError() } public ErrorInfo GetError() => AsError().Error; + + public static implicit operator ModelResult(ErrorInfo errorInfo) + { + return new ErrorModelResult(errorInfo); + } } public abstract class ModelResult : IModelResult @@ -93,6 +98,11 @@ public static implicit operator ModelResult(ErrorModelResult modelResult) return (ErrorModelResult) modelResult; } + public static implicit operator ModelResult(ErrorInfo errorInfo) + { + return new ErrorModelResult(errorInfo); + } + public bool TryGetResult(out T resultValue) { if (IsOk())