@@ -20,9 +20,9 @@ public CatalogController(CatalogContext context, IOptionsSnapshot<CatalogSetting
20
20
// GET api/v1/[controller]/items[?pageSize=3&pageIndex=10]
21
21
[ HttpGet ]
22
22
[ Route ( "items" ) ]
23
- [ ProducesResponseType ( typeof ( PaginatedItemsViewModel < CatalogItem > ) , ( int ) HttpStatusCode . OK ) ]
24
- [ ProducesResponseType ( typeof ( IEnumerable < CatalogItem > ) , ( int ) HttpStatusCode . OK ) ]
25
- [ ProducesResponseType ( ( int ) HttpStatusCode . BadRequest ) ]
23
+ [ ProducesResponseType ( typeof ( PaginatedItemsViewModel < CatalogItem > ) , StatusCodes . Status200OK ) ]
24
+ [ ProducesResponseType ( typeof ( IEnumerable < CatalogItem > ) , StatusCodes . Status200OK ) ]
25
+ [ ProducesResponseType ( StatusCodes . Status400BadRequest ) ]
26
26
public async Task < IActionResult > ItemsAsync ( [ FromQuery ] int pageSize = 10 , [ FromQuery ] int pageIndex = 0 , string ids = null )
27
27
{
28
28
if ( ! string . IsNullOrEmpty ( ids ) )
@@ -74,9 +74,8 @@ private async Task<List<CatalogItem>> GetItemsByIdsAsync(string ids)
74
74
75
75
[ HttpGet ]
76
76
[ Route ( "items/{id:int}" ) ]
77
- [ ProducesResponseType ( ( int ) HttpStatusCode . NotFound ) ]
78
- [ ProducesResponseType ( ( int ) HttpStatusCode . BadRequest ) ]
79
- [ ProducesResponseType ( typeof ( CatalogItem ) , ( int ) HttpStatusCode . OK ) ]
77
+ [ ProducesResponseType ( StatusCodes . Status404NotFound ) ]
78
+ [ ProducesResponseType ( StatusCodes . Status400BadRequest ) ]
80
79
public async Task < ActionResult < CatalogItem > > ItemByIdAsync ( int id )
81
80
{
82
81
if ( id <= 0 )
@@ -102,7 +101,6 @@ public async Task<ActionResult<CatalogItem>> ItemByIdAsync(int id)
102
101
// GET api/v1/[controller]/items/withname/samplename[?pageSize=3&pageIndex=10]
103
102
[ HttpGet ]
104
103
[ Route ( "items/withname/{name:minlength(1)}" ) ]
105
- [ ProducesResponseType ( typeof ( PaginatedItemsViewModel < CatalogItem > ) , ( int ) HttpStatusCode . OK ) ]
106
104
public async Task < ActionResult < PaginatedItemsViewModel < CatalogItem > > > ItemsWithNameAsync ( string name , [ FromQuery ] int pageSize = 10 , [ FromQuery ] int pageIndex = 0 )
107
105
{
108
106
var totalItems = await _catalogContext . CatalogItems
@@ -123,7 +121,6 @@ public async Task<ActionResult<PaginatedItemsViewModel<CatalogItem>>> ItemsWithN
123
121
// GET api/v1/[controller]/items/type/1/brand[?pageSize=3&pageIndex=10]
124
122
[ HttpGet ]
125
123
[ Route ( "items/type/{catalogTypeId}/brand/{catalogBrandId:int?}" ) ]
126
- [ ProducesResponseType ( typeof ( PaginatedItemsViewModel < CatalogItem > ) , ( int ) HttpStatusCode . OK ) ]
127
124
public async Task < ActionResult < PaginatedItemsViewModel < CatalogItem > > > ItemsByTypeIdAndBrandIdAsync ( int catalogTypeId , int ? catalogBrandId , [ FromQuery ] int pageSize = 10 , [ FromQuery ] int pageIndex = 0 )
128
125
{
129
126
var root = ( IQueryable < CatalogItem > ) _catalogContext . CatalogItems ;
@@ -151,7 +148,6 @@ public async Task<ActionResult<PaginatedItemsViewModel<CatalogItem>>> ItemsByTyp
151
148
// GET api/v1/[controller]/items/type/all/brand[?pageSize=3&pageIndex=10]
152
149
[ HttpGet ]
153
150
[ Route ( "items/type/all/brand/{catalogBrandId:int?}" ) ]
154
- [ ProducesResponseType ( typeof ( PaginatedItemsViewModel < CatalogItem > ) , ( int ) HttpStatusCode . OK ) ]
155
151
public async Task < ActionResult < PaginatedItemsViewModel < CatalogItem > > > ItemsByBrandIdAsync ( int ? catalogBrandId , [ FromQuery ] int pageSize = 10 , [ FromQuery ] int pageIndex = 0 )
156
152
{
157
153
var root = ( IQueryable < CatalogItem > ) _catalogContext . CatalogItems ;
@@ -177,7 +173,6 @@ public async Task<ActionResult<PaginatedItemsViewModel<CatalogItem>>> ItemsByBra
177
173
// GET api/v1/[controller]/CatalogTypes
178
174
[ HttpGet ]
179
175
[ Route ( "catalogtypes" ) ]
180
- [ ProducesResponseType ( typeof ( List < CatalogType > ) , ( int ) HttpStatusCode . OK ) ]
181
176
public async Task < ActionResult < List < CatalogType > > > CatalogTypesAsync ( )
182
177
{
183
178
return await _catalogContext . CatalogTypes . ToListAsync ( ) ;
@@ -186,7 +181,6 @@ public async Task<ActionResult<List<CatalogType>>> CatalogTypesAsync()
186
181
// GET api/v1/[controller]/CatalogBrands
187
182
[ HttpGet ]
188
183
[ Route ( "catalogbrands" ) ]
189
- [ ProducesResponseType ( typeof ( List < CatalogBrand > ) , ( int ) HttpStatusCode . OK ) ]
190
184
public async Task < ActionResult < List < CatalogBrand > > > CatalogBrandsAsync ( )
191
185
{
192
186
return await _catalogContext . CatalogBrands . ToListAsync ( ) ;
@@ -195,8 +189,8 @@ public async Task<ActionResult<List<CatalogBrand>>> CatalogBrandsAsync()
195
189
//PUT api/v1/[controller]/items
196
190
[ Route ( "items" ) ]
197
191
[ HttpPut ]
198
- [ ProducesResponseType ( ( int ) HttpStatusCode . NotFound ) ]
199
- [ ProducesResponseType ( ( int ) HttpStatusCode . Created ) ]
192
+ [ ProducesResponseType ( StatusCodes . Status404NotFound ) ]
193
+ [ ProducesResponseType ( StatusCodes . Status201Created ) ]
200
194
public async Task < ActionResult > UpdateProductAsync ( [ FromBody ] CatalogItem productToUpdate )
201
195
{
202
196
var catalogItem = await _catalogContext . CatalogItems . SingleOrDefaultAsync ( i => i . Id == productToUpdate . Id ) ;
@@ -235,7 +229,7 @@ public async Task<ActionResult> UpdateProductAsync([FromBody] CatalogItem produc
235
229
//POST api/v1/[controller]/items
236
230
[ Route ( "items" ) ]
237
231
[ HttpPost ]
238
- [ ProducesResponseType ( ( int ) HttpStatusCode . Created ) ]
232
+ [ ProducesResponseType ( StatusCodes . Status201Created ) ]
239
233
public async Task < ActionResult > CreateProductAsync ( [ FromBody ] CatalogItem product )
240
234
{
241
235
var item = new CatalogItem
@@ -258,8 +252,8 @@ public async Task<ActionResult> CreateProductAsync([FromBody] CatalogItem produc
258
252
//DELETE api/v1/[controller]/id
259
253
[ Route ( "{id}" ) ]
260
254
[ HttpDelete ]
261
- [ ProducesResponseType ( ( int ) HttpStatusCode . NoContent ) ]
262
- [ ProducesResponseType ( ( int ) HttpStatusCode . NotFound ) ]
255
+ [ ProducesResponseType ( StatusCodes . Status204NoContent ) ]
256
+ [ ProducesResponseType ( StatusCodes . Status404NotFound ) ]
263
257
public async Task < ActionResult > DeleteProductAsync ( int id )
264
258
{
265
259
var product = _catalogContext . CatalogItems . SingleOrDefault ( x => x . Id == id ) ;
0 commit comments