12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- namespace ProductionLineMonitor.Application.Services
- {
- public enum CodeEnum
- {
- Success,
- Fail,
- Error
- }
- public class Result
- {
- public Result() { }
- public Result(CodeEnum code, string message)
- {
- Code = code;
- Message = message;
- }
- public CodeEnum Code { get; set; }
- public string Message { get; set; }
- public static Result Success()
- {
- return new Result(CodeEnum.Success, "Ok!");
- }
- public static Result Fail(string message)
- {
- return new Result(CodeEnum.Fail, message);
- }
- public static Result Error(string error)
- {
- return new Result(CodeEnum.Error, error);
- }
- }
- public class Result<T> : Result
- {
- public Result() : base() { }
- public Result(CodeEnum code, string message)
- : base(code, message)
- {
- }
- public Result(CodeEnum code, string message, T data)
- : base(code, message)
- {
- Data = data;
- }
- public T Data { get; set; }
- public static new Result<T> Success()
- {
- return new Result<T>(CodeEnum.Success, "Ok!");
- }
- public static Result<T> Success(T data)
- {
- return new Result<T>(CodeEnum.Success, "Ok!", data);
- }
- public static new Result<T> Fail(string message)
- {
- return new Result<T>(CodeEnum.Fail, message);
- }
- public static new Result<T> Error(string message)
- {
- return new Result<T>(CodeEnum.Error, message);
- }
- }
- }
|