BllResult.cs
3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
using System;
namespace RCS.Model.Comm
{
public class BllResult<T>
{
public BllResult(bool success, string msg, T data)
{
code = 200;
if (success)
{
code = 200;
}
else
{
code = 400;
}
IsSuccess = success;
Message = msg;
Data = data;
}
public int code { get; set; }
public bool IsSuccess { get; set; }
public string Message { get; set; }
public T Data { get; set; }
public static BllResult<T> Success(T data, string msg)
{
return new BllResult<T>(true, msg, data);
}
public static BllResult<T> Success(T data)
{
return new BllResult<T>(true, "", data);
}
public static BllResult<T> Success(string msg)
{
return new BllResult<T>(true, msg, default);
}
public static BllResult<T> Success()
{
return new BllResult<T>(true, "", default);
}
public static BllResult<T> Error(T data, string msg)
{
return new BllResult<T>(false, msg, data);
}
public static BllResult<T> Error(T data)
{
return new BllResult<T>(false, "", data);
}
public static BllResult<T> Error(string msg)
{
return new BllResult<T>(false, msg, default);
}
public static BllResult<T> Error()
{
return new BllResult<T>(false, "", default);
}
}
public class BllResult
{
public BllResult(bool success, string msg, object data)
{
code = 200;
if (success)
{
code = 200;
}
else
{
code = 400;
}
IsSuccess = success;
Message = msg;
Data = data;
}
public int code { get; set; }
public bool IsSuccess { get; set; }
public string Message { get; set; }
public object Data { get; set; }
public static BllResult Success(object data, string msg)
{
return new BllResult(true, msg, data);
}
public static BllResult Success(object data)
{
return new BllResult(true, "", data);
}
public static BllResult Success(string msg)
{
return new BllResult(true, msg, null);
}
public static BllResult Success()
{
return new BllResult(true, "", null);
}
public static BllResult Error(object data, string msg)
{
return new BllResult(false, msg, data);
}
public static BllResult Error(object data)
{
return new BllResult(false, "", data);
}
public static BllResult Error(string msg)
{
return new BllResult(false, msg, null);
}
public static BllResult Error()
{
return new BllResult(false, "", null);
}
}
}