@@ -13,7 +13,8 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API.Controllers
1313{
1414 [ Route ( "api/v1/[controller]" ) ]
1515 [ Authorize ]
16- public class BasketController : Controller
16+ [ ApiController ]
17+ public class BasketController : ControllerBase
1718 {
1819 private readonly IBasketRepository _repository ;
1920 private readonly IIdentityService _identitySvc ;
@@ -31,32 +32,31 @@ public BasketController(IBasketRepository repository,
3132 // GET /id
3233 [ HttpGet ( "{id}" ) ]
3334 [ ProducesResponseType ( typeof ( CustomerBasket ) , ( int ) HttpStatusCode . OK ) ]
34- public async Task < IActionResult > Get ( string id )
35+ public async Task < ActionResult < CustomerBasket > > Get ( string id )
3536 {
3637 var basket = await _repository . GetBasketAsync ( id ) ;
38+
3739 if ( basket == null )
3840 {
39- return Ok ( new CustomerBasket ( id ) { } ) ;
41+ return new CustomerBasket ( id ) ;
4042 }
4143
42- return Ok ( basket ) ;
44+ return basket ;
4345 }
4446
4547 // POST /value
4648 [ HttpPost ]
4749 [ ProducesResponseType ( typeof ( CustomerBasket ) , ( int ) HttpStatusCode . OK ) ]
48- public async Task < IActionResult > Post ( [ FromBody ] CustomerBasket value )
50+ public async Task < ActionResult < CustomerBasket > > Post ( [ FromBody ] CustomerBasket value )
4951 {
50- var basket = await _repository . UpdateBasketAsync ( value ) ;
51-
52- return Ok ( basket ) ;
52+ return await _repository . UpdateBasketAsync ( value ) ;
5353 }
5454
5555 [ Route ( "checkout" ) ]
5656 [ HttpPost ]
5757 [ ProducesResponseType ( ( int ) HttpStatusCode . Accepted ) ]
5858 [ ProducesResponseType ( ( int ) HttpStatusCode . BadRequest ) ]
59- public async Task < IActionResult > Checkout ( [ FromBody ] BasketCheckout basketCheckout , [ FromHeader ( Name = "x-requestid" ) ] string requestId )
59+ public async Task < ActionResult > Checkout ( [ FromBody ] BasketCheckout basketCheckout , [ FromHeader ( Name = "x-requestid" ) ] string requestId )
6060 {
6161 var userId = _identitySvc . GetUserIdentity ( ) ;
6262
@@ -91,6 +91,5 @@ public void Delete(string id)
9191 {
9292 _repository . DeleteBasketAsync ( id ) ;
9393 }
94-
9594 }
9695}
0 commit comments