using DotBased.AspNet.Authority.Models.Validation; namespace DotBased.AspNet.Authority.Models; public class AuthorityResult { public AuthorityResult(bool success, string errorMessage = "", TResultValue? value = default, ResultFailReason reason = ResultFailReason.None, List? errors = null) { Success = success; ErrorMessage = errorMessage; Value = value; Reason = reason; ValidationErrors = errors; } public bool Success { get; } public string ErrorMessage { get; } public TResultValue? Value { get; } public ResultFailReason Reason { get; } public List? ValidationErrors { get; } public static AuthorityResult Ok(TResultValue? value) => new AuthorityResult(true, value:value); public static AuthorityResult Error(string errorMessage, ResultFailReason reason = ResultFailReason.Error) => new AuthorityResult(false, errorMessage, reason:reason); public static AuthorityResult Failed(List errors, ResultFailReason reason = ResultFailReason.None) => new AuthorityResult(false, errors:errors, reason:reason); } public enum ResultFailReason { None, Unknown, Validation, Error }