File tree Expand file tree Collapse file tree
src/ApiGateways/Mobile.Bff.Shopping/aggregator/Controllers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,15 +36,9 @@ public async Task<ActionResult<BasketData>> UpdateAllBasketAsync([FromBody] Upda
3636 }
3737
3838 // Retrieve the current basket
39- var currentBasket = await _basket . GetByIdAsync ( data . BuyerId ) ;
40-
41- if ( currentBasket == null )
42- {
43- currentBasket = new BasketData ( data . BuyerId ) ;
44- }
39+ var basket = await _basket . GetByIdAsync ( data . BuyerId ) ?? new BasketData ( data . BuyerId ) ;
4540
4641 var catalogItems = await _catalog . GetCatalogItemsAsync ( data . Items . Select ( x => x . ProductId ) ) ;
47- var newBasket = new BasketData ( data . BuyerId ) ;
4842
4943 foreach ( var bitem in data . Items )
5044 {
@@ -54,7 +48,7 @@ public async Task<ActionResult<BasketData>> UpdateAllBasketAsync([FromBody] Upda
5448 return BadRequest ( $ "Basket refers to a non-existing catalog item ({ bitem . ProductId } )") ;
5549 }
5650
57- newBasket . Items . Add ( new BasketDataItem ( )
51+ basket . Items . Add ( new BasketDataItem ( )
5852 {
5953 Id = bitem . Id ,
6054 ProductId = catalogItem . Id . ToString ( ) ,
@@ -65,9 +59,9 @@ public async Task<ActionResult<BasketData>> UpdateAllBasketAsync([FromBody] Upda
6559 } ) ;
6660 }
6761
68- await _basket . UpdateAsync ( newBasket ) ;
62+ await _basket . UpdateAsync ( basket ) ;
6963
70- return newBasket ;
64+ return basket ;
7165 }
7266
7367 [ HttpPut ]
You can’t perform that action at this time.
0 commit comments