@@ -28,7 +28,7 @@ public FoodsController(IUrlHelper urlHelper, IFoodRepository foodRepository)
28
28
}
29
29
30
30
[ HttpGet ( Name = nameof ( GetAllFoods ) ) ]
31
- public ActionResult < object > GetAllFoods ( [ FromQuery ] QueryParameters queryParameters )
31
+ public ActionResult GetAllFoods ( [ FromQuery ] QueryParameters queryParameters )
32
32
{
33
33
List < FoodItem > foodItems = _foodRepository . GetAll ( queryParameters ) . ToList ( ) ;
34
34
@@ -58,7 +58,7 @@ public ActionResult<object> GetAllFoods([FromQuery] QueryParameters queryParamet
58
58
59
59
[ HttpGet ]
60
60
[ Route ( "{id:int}" , Name = nameof ( GetSingleFood ) ) ]
61
- public ActionResult < OkObjectResult > GetSingleFood ( int id )
61
+ public ActionResult GetSingleFood ( int id )
62
62
{
63
63
FoodItem foodItem = _foodRepository . GetSingle ( id ) ;
64
64
@@ -71,7 +71,7 @@ public ActionResult<OkObjectResult> GetSingleFood(int id)
71
71
}
72
72
73
73
[ HttpPost ( Name = nameof ( AddFood ) ) ]
74
- public ActionResult < CreatedAtRouteResult > AddFood ( [ FromBody ] FoodCreateDto foodCreateDto )
74
+ public ActionResult < FoodItemDto > AddFood ( [ FromBody ] FoodCreateDto foodCreateDto )
75
75
{
76
76
if ( foodCreateDto == null )
77
77
{
@@ -99,7 +99,7 @@ public ActionResult<CreatedAtRouteResult> AddFood([FromBody] FoodCreateDto foodC
99
99
}
100
100
101
101
[ HttpPatch ( "{id:int}" , Name = nameof ( PartiallyUpdateFood ) ) ]
102
- public ActionResult < OkObjectResult > PartiallyUpdateFood ( int id , [ FromBody ] JsonPatchDocument < FoodUpdateDto > patchDoc )
102
+ public ActionResult < FoodItemDto > PartiallyUpdateFood ( int id , [ FromBody ] JsonPatchDocument < FoodUpdateDto > patchDoc )
103
103
{
104
104
if ( patchDoc == null )
105
105
{
@@ -136,7 +136,7 @@ public ActionResult<OkObjectResult> PartiallyUpdateFood(int id, [FromBody] JsonP
136
136
137
137
[ HttpDelete ]
138
138
[ Route ( "{id:int}" , Name = nameof ( RemoveFood ) ) ]
139
- public ActionResult < NoContentResult > RemoveFood ( int id )
139
+ public ActionResult RemoveFood ( int id )
140
140
{
141
141
FoodItem foodItem = _foodRepository . GetSingle ( id ) ;
142
142
@@ -157,7 +157,7 @@ public ActionResult<NoContentResult> RemoveFood(int id)
157
157
158
158
[ HttpPut ]
159
159
[ Route ( "{id:int}" , Name = nameof ( UpdateFood ) ) ]
160
- public ActionResult < OkObjectResult > UpdateFood ( int id , [ FromBody ] FoodUpdateDto foodUpdateDto )
160
+ public ActionResult < FoodItemDto > UpdateFood ( int id , [ FromBody ] FoodUpdateDto foodUpdateDto )
161
161
{
162
162
if ( foodUpdateDto == null )
163
163
{
@@ -189,7 +189,7 @@ public ActionResult<OkObjectResult> UpdateFood(int id, [FromBody]FoodUpdateDto f
189
189
}
190
190
191
191
[ HttpGet ( "GetRandomMeal" , Name = nameof ( GetRandomMeal ) ) ]
192
- public ActionResult < object > GetRandomMeal ( )
192
+ public ActionResult GetRandomMeal ( )
193
193
{
194
194
ICollection < FoodItem > foodItems = _foodRepository . GetRandomMeal ( ) ;
195
195
@@ -255,6 +255,11 @@ private List<LinkDto> CreateLinksForCollection(QueryParameters queryParameters,
255
255
} ) , "previous" , "GET" ) ) ;
256
256
}
257
257
258
+ links . Add (
259
+ new LinkDto ( _urlHelper . Link ( nameof ( AddFood ) , null ) ,
260
+ "create_food" ,
261
+ "POST" ) ) ;
262
+
258
263
return links ;
259
264
}
260
265
0 commit comments