@@ -8,4 +8,96 @@ public class BaseResponse<T> : IBaseResponse<T>
8
8
public StatusCodes StatusCode { get ; set ; }
9
9
10
10
public T Data { get ; set ; }
11
+
12
+ // Ok response generate (200)
13
+ public static BaseResponse < T > Ok ( T data , string description = "" )
14
+ {
15
+ return new BaseResponse < T > ( )
16
+ {
17
+ Data = data ,
18
+ StatusCode = StatusCodes . Ok ,
19
+ Description = description ,
20
+ } ;
21
+ }
22
+
23
+ // Empty Ok response generate (200)
24
+ public static BaseResponse < T > Ok ( string description = "" )
25
+ {
26
+ return new BaseResponse < T > ( )
27
+ {
28
+ StatusCode = StatusCodes . Ok ,
29
+ Description = description ,
30
+ } ;
31
+ }
32
+
33
+ // Created response generate (201)
34
+ public static BaseResponse < T > Created ( T data , string description = "" )
35
+ {
36
+ return new BaseResponse < T > ( )
37
+ {
38
+ Data = data ,
39
+ StatusCode = StatusCodes . Created ,
40
+ Description = description ,
41
+ } ;
42
+ }
43
+
44
+ // Empty Created response generate (201)
45
+ public static BaseResponse < T > Created ( string description = "" )
46
+ {
47
+ return new BaseResponse < T > ( )
48
+ {
49
+ StatusCode = StatusCodes . Created ,
50
+ Description = description ,
51
+ } ;
52
+ }
53
+
54
+ // NoContent response generate (204)
55
+ public static BaseResponse < T > NoContent ( string description = "" )
56
+ {
57
+ return new BaseResponse < T > ( )
58
+ {
59
+ StatusCode = StatusCodes . NoContent ,
60
+ Description = description ,
61
+ } ;
62
+ }
63
+
64
+ // Unauthorized response generate (401)
65
+ public static BaseResponse < T > Unauthorized ( string description = "" )
66
+ {
67
+ return new BaseResponse < T > ( )
68
+ {
69
+ StatusCode = StatusCodes . Unauthorized ,
70
+ Description = description ,
71
+ } ;
72
+ }
73
+
74
+ // NotFound response generate (404)
75
+ public static BaseResponse < T > NotFound ( string description = "" )
76
+ {
77
+ return new BaseResponse < T > ( )
78
+ {
79
+ StatusCode = StatusCodes . NotFound ,
80
+ Description = description ,
81
+ } ;
82
+ }
83
+
84
+ // Conflict response generate (409)
85
+ public static BaseResponse < T > Conflict ( string description = "" )
86
+ {
87
+ return new BaseResponse < T > ( )
88
+ {
89
+ StatusCode = StatusCodes . Conflict ,
90
+ Description = description ,
91
+ } ;
92
+ }
93
+
94
+ // InternalServerError response generate (500)
95
+ public static BaseResponse < T > InternalServerError ( string description = "" )
96
+ {
97
+ return new BaseResponse < T > ( )
98
+ {
99
+ StatusCode = StatusCodes . InternalServerError ,
100
+ Description = description ,
101
+ } ;
102
+ }
11
103
}
0 commit comments