6
6
using Microsoft . AspNetCore . Mvc ;
7
7
using Microsoft . AspNetCore . OData . Deltas ;
8
8
using Microsoft . AspNetCore . OData . Extensions ;
9
- using Microsoft . AspNetCore . OData . Formatter ;
10
9
using Microsoft . AspNetCore . OData . Query ;
11
10
using Microsoft . AspNetCore . OData . Results ;
12
11
using Microsoft . AspNetCore . OData . Routing . Controllers ;
@@ -31,6 +30,7 @@ public class ProductsController : ODataController
31
30
/// </summary>
32
31
/// <returns>All available products.</returns>
33
32
/// <response code="200">Products successfully retrieved.</response>
33
+ [ HttpGet ]
34
34
[ EnableQuery ]
35
35
[ Produces ( "application/json" ) ]
36
36
[ ProducesResponseType ( typeof ( ODataValue < IEnumerable < Product > > ) , Status200OK ) ]
@@ -43,6 +43,7 @@ public class ProductsController : ODataController
43
43
/// <returns>The requested product.</returns>
44
44
/// <response code="200">The product was successfully retrieved.</response>
45
45
/// <response code="404">The product does not exist.</response>
46
+ [ HttpGet ]
46
47
[ EnableQuery ]
47
48
[ Produces ( "application/json" ) ]
48
49
[ ProducesResponseType ( typeof ( Product ) , Status200OK ) ]
@@ -58,6 +59,7 @@ public SingleResult<Product> Get( int key ) =>
58
59
/// <response code="201">The product was successfully created.</response>
59
60
/// <response code="204">The product was successfully created.</response>
60
61
/// <response code="400">The product is invalid.</response>
62
+ [ HttpPost ]
61
63
[ Produces ( "application/json" ) ]
62
64
[ ProducesResponseType ( typeof ( Product ) , Status201Created ) ]
63
65
[ ProducesResponseType ( Status204NoContent ) ]
@@ -84,6 +86,7 @@ public IActionResult Post( [FromBody] Product product )
84
86
/// <response code="204">The product was successfully updated.</response>
85
87
/// <response code="400">The product is invalid.</response>
86
88
/// <response code="404">The product does not exist.</response>
89
+ [ HttpPatch ]
87
90
[ Produces ( "application/json" ) ]
88
91
[ ProducesResponseType ( typeof ( Product ) , Status200OK ) ]
89
92
[ ProducesResponseType ( Status204NoContent ) ]
@@ -113,6 +116,7 @@ public IActionResult Patch( int key, [FromBody] Delta<Product> delta )
113
116
/// <response code="204">The product was successfully updated.</response>
114
117
/// <response code="400">The product is invalid.</response>
115
118
/// <response code="404">The product does not exist.</response>
119
+ [ HttpPut ]
116
120
[ Produces ( "application/json" ) ]
117
121
[ ProducesResponseType ( typeof ( Product ) , Status200OK ) ]
118
122
[ ProducesResponseType ( Status204NoContent ) ]
@@ -134,6 +138,7 @@ public IActionResult Put( int key, [FromBody] Product update )
134
138
/// <param name="key">The product to delete.</param>
135
139
/// <returns>None</returns>
136
140
/// <response code="204">The product was successfully deleted.</response>
141
+ [ HttpDelete ]
137
142
[ ProducesResponseType ( Status204NoContent ) ]
138
143
[ ProducesResponseType ( Status404NotFound ) ]
139
144
public IActionResult Delete ( int key ) => NoContent ( ) ;
@@ -144,7 +149,7 @@ public IActionResult Put( int key, [FromBody] Product update )
144
149
/// <param name="key">The product identifier.</param>
145
150
/// <returns>The supplier</returns>
146
151
/// <returns>The requested supplier.</returns>
147
- [ HttpGet ( "api/Products/{key}/Supplier" ) ]
152
+ [ HttpGet ]
148
153
[ EnableQuery ]
149
154
[ Produces ( "application/json" ) ]
150
155
[ ProducesResponseType ( typeof ( Supplier ) , Status200OK ) ]
@@ -158,6 +163,7 @@ public SingleResult<Supplier> GetSupplier( int key ) =>
158
163
/// <param name="key">The product identifier.</param>
159
164
/// <param name="navigationProperty">The name of the related navigation property.</param>
160
165
/// <returns>The supplier link.</returns>
166
+ [ HttpGet ]
161
167
[ Produces ( "application/json" ) ]
162
168
[ ProducesResponseType ( typeof ( ODataId ) , Status200OK ) ]
163
169
[ ProducesResponseType ( Status404NotFound ) ]
@@ -181,6 +187,7 @@ public IActionResult GetRef( int key, string navigationProperty )
181
187
/// <param name="navigationProperty">The name of the related navigation property.</param>
182
188
/// <param name="link">The related entity identifier.</param>
183
189
/// <returns>None</returns>
190
+ [ HttpPut ]
184
191
[ ProducesResponseType ( Status204NoContent ) ]
185
192
[ ProducesResponseType ( Status404NotFound ) ]
186
193
public IActionResult CreateRef (
@@ -195,6 +202,7 @@ public IActionResult CreateRef(
195
202
/// <param name="navigationProperty">The name of the related navigation property.</param>
196
203
/// <param name="relatedKey">The related entity identifier.</param>
197
204
/// <returns>None</returns>
205
+ [ HttpDelete ]
198
206
[ ProducesResponseType ( Status204NoContent ) ]
199
207
[ ProducesResponseType ( Status404NotFound ) ]
200
208
public IActionResult DeleteRef (
0 commit comments