File tree Expand file tree Collapse file tree
Mobile.Bff.Shopping/aggregator/Controllers
Web.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 ]
Original file line number Diff line number Diff line change @@ -36,14 +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- if ( currentBasket == null )
41- {
42- currentBasket = new BasketData ( data . BuyerId ) ;
43- }
39+ var basket = await _basket . GetByIdAsync ( data . BuyerId ) ?? new BasketData ( data . BuyerId ) ;
4440
4541 var catalogItems = await _catalog . GetCatalogItemsAsync ( data . Items . Select ( x => x . ProductId ) ) ;
46- var newBasket = new BasketData ( data . BuyerId ) ;
4742
4843 foreach ( var bitem in data . Items )
4944 {
@@ -53,7 +48,7 @@ public async Task<ActionResult<BasketData>> UpdateAllBasketAsync([FromBody] Upda
5348 return BadRequest ( $ "Basket refers to a non-existing catalog item ({ bitem . ProductId } )") ;
5449 }
5550
56- newBasket . Items . Add ( new BasketDataItem ( )
51+ basket . Items . Add ( new BasketDataItem ( )
5752 {
5853 Id = bitem . Id ,
5954 ProductId = catalogItem . Id . ToString ( ) ,
@@ -64,9 +59,9 @@ public async Task<ActionResult<BasketData>> UpdateAllBasketAsync([FromBody] Upda
6459 } ) ;
6560 }
6661
67- await _basket . UpdateAsync ( newBasket ) ;
62+ await _basket . UpdateAsync ( basket ) ;
6863
69- return newBasket ;
64+ return basket ;
7065 }
7166
7267 [ HttpPut ]
You can’t perform that action at this time.
0 commit comments