@@ -96,18 +96,6 @@ public async Task UpdateAsync(BasketData currentBasket)
9696 }
9797 }
9898 }
99-
100-
101-
102-
103- //_httpClient.BaseAddress = new Uri(_urls.Basket + UrlsConfig.BasketOperations.UpdateBasket());
104-
105- //var client = GrpcClient.Create<Basket.BasketClient>(_httpClient);
106- //_logger.LogInformation("Grpc update basket currentBasket {@currentBasket}", currentBasket);
107- //var request = MapToCustomerBasketRequest(currentBasket);
108- //_logger.LogInformation("Grpc update basket request {@request}", request);
109-
110- //await client.UpdateBasketAsync(request);
11199 }
112100
113101 private BasketData MapToBasketData ( CustomerBasketResponse customerBasketRequest )
@@ -122,16 +110,22 @@ private BasketData MapToBasketData(CustomerBasketResponse customerBasketRequest)
122110 BuyerId = customerBasketRequest . Buyerid
123111 } ;
124112
125- customerBasketRequest . Items . ToList ( ) . ForEach ( item => map . Items . Add ( new BasketDataItem
113+ customerBasketRequest . Items . ToList ( ) . ForEach ( item =>
126114 {
127- Id = item . Id ,
128- OldUnitPrice = ( decimal ) item . Oldunitprice ,
129- PictureUrl = item . Pictureurl ,
130- ProductId = item . Productid ,
131- ProductName = item . Productname ,
132- Quantity = item . Quantity ,
133- UnitPrice = ( decimal ) item . Unitprice
134- } ) ) ;
115+ if ( item . Id != null )
116+ {
117+ map . Items . Add ( new BasketDataItem
118+ {
119+ Id = item . Id ,
120+ OldUnitPrice = ( decimal ) item . Oldunitprice ,
121+ PictureUrl = item . Pictureurl ,
122+ ProductId = item . Productid ,
123+ ProductName = item . Productname ,
124+ Quantity = item . Quantity ,
125+ UnitPrice = ( decimal ) item . Unitprice
126+ } ) ;
127+ }
128+ } ) ;
135129
136130 return map ;
137131 }
@@ -148,16 +142,22 @@ private CustomerBasketRequest MapToCustomerBasketRequest(BasketData basketData)
148142 Buyerid = basketData . BuyerId
149143 } ;
150144
151- basketData . Items . ToList ( ) . ForEach ( item => map . Items . Add ( new BasketItemResponse
145+ basketData . Items . ToList ( ) . ForEach ( item =>
152146 {
153- Id = item . Id ,
154- Oldunitprice = ( double ) item . OldUnitPrice ,
155- Pictureurl = item . PictureUrl ,
156- Productid = item . ProductId ,
157- Productname = item . ProductName ,
158- Quantity = item . Quantity ,
159- Unitprice = ( double ) item . UnitPrice
160- } ) ) ;
147+ if ( item . Id != null )
148+ {
149+ map . Items . Add ( new BasketItemResponse
150+ {
151+ Id = item . Id ,
152+ Oldunitprice = ( double ) item . OldUnitPrice ,
153+ Pictureurl = item . PictureUrl ,
154+ Productid = item . ProductId ,
155+ Productname = item . ProductName ,
156+ Quantity = item . Quantity ,
157+ Unitprice = ( double ) item . UnitPrice
158+ } ) ;
159+ }
160+ } ) ;
161161
162162 return map ;
163163 }
0 commit comments