NonInventPurchasingSystem/CPRNIMS.Domain/Services/Result.cs
2026-04-21 11:59:21 +08:00

26 lines
701 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Services
{
public class Result<T>
{
public bool IsSuccess { get; set; }
public string? Error { get; set; }
public T? Value { get; set; }
private Result(bool isSuccess, T? value, string? error)
{
IsSuccess = isSuccess;
Error = error;
Value = value;
}
public static Result<T> Success(T value)
=> new Result<T>(true, value, null);
public static Result<T> Failure(string? error)
=> new Result<T>(false, default, error);
}
}