namespace Safeguard.Dtos { public enum CodeEnum { Success, Fail, Error } public class ResultDto { public ResultDto(CodeEnum? code, string? message) { Code = code; Message = message; } public CodeEnum? Code { get; set; } public string? Message { get; set; } public static ResultDto Success() { return new ResultDto(CodeEnum.Success, "Ok!"); } public static ResultDto Fail(string message) { return new ResultDto(CodeEnum.Fail, message); } public static ResultDto Error(string error) { return new ResultDto(CodeEnum.Error, error); } } public class ResultDto : ResultDto { public ResultDto(CodeEnum code, string? message) : base(code, message) { } public ResultDto(CodeEnum code, string? message, T? data) : base(code, message) { Data = data; } public T? Data { get; set; } public static new ResultDto Success() { return new ResultDto(CodeEnum.Success, "Ok!"); } public static ResultDto Success(T data) { return new ResultDto(CodeEnum.Success, "Ok!", data); } public static new ResultDto Fail(string message) { return new ResultDto(CodeEnum.Fail, message); } public static new ResultDto Error(string message) { return new ResultDto(CodeEnum.Error, message); } } }