@@ -349,36 +349,64 @@ public async Task<bool> DeletePartSupplierAsync(PartSupplier partSupplier)
349
349
// get details on this mouser part
350
350
if ( string . IsNullOrEmpty ( lineItem . MouserPartNumber ) )
351
351
continue ;
352
- var partResponse = await mouserApi . GetProductDetailsAsync ( lineItem . MouserPartNumber ) ;
353
- if ( ! partResponse . RequiresAuthentication && partResponse ? . Errors . Any ( ) == false )
352
+ if ( ( ( MouserConfiguration ) mouserApi . Configuration ) . IsConfigured )
354
353
{
355
- if ( partResponse . Response != null )
354
+ // request additional information for the part as orders doesn't return much
355
+ var partResponse = await mouserApi . GetProductDetailsAsync ( lineItem . MouserPartNumber ) ;
356
+ if ( ! partResponse . RequiresAuthentication && partResponse ? . Errors . Any ( ) == false )
356
357
{
357
- var searchResults = ( ICollection < MouserPart > ) partResponse . Response ;
358
- // convert the part to a common part
359
- var part = searchResults . First ( ) ;
360
- commonParts . Add ( new CommonPart
358
+ if ( partResponse . Response != null )
361
359
{
362
- SupplierPartNumber = part . MouserPartNumber ,
363
- Supplier = "Mouser" ,
364
- ManufacturerPartNumber = part . ManufacturerPartNumber ,
365
- Manufacturer = part . Manufacturer ,
366
- Description = part . Description ,
367
- ImageUrl = part . ImagePath ,
368
- DatasheetUrls = new List < string > { part . DataSheetUrl ?? string . Empty } ,
369
- ProductUrl = part . ProductDetailUrl ,
370
- Status = part . LifecycleStatus ,
371
- Currency = mouserOrderResponse . CurrencyCode ,
372
- AdditionalPartNumbers = new List < string > ( ) ,
373
- BasePartNumber = part . ManufacturerPartNumber ,
374
- MountingTypeId = 0 ,
375
- PackageType = "" ,
376
- Cost = lineItem . UnitPrice ,
377
- QuantityAvailable = lineItem . Quantity ,
378
- Reference = lineItem . CartItemCustPartNumber ,
379
- } ) ;
360
+ var searchResults = ( ICollection < MouserPart > ) partResponse . Response ;
361
+ // convert the part to a common part
362
+ var part = searchResults . First ( ) ;
363
+ commonParts . Add ( new CommonPart
364
+ {
365
+ SupplierPartNumber = part . MouserPartNumber ,
366
+ Supplier = "Mouser" ,
367
+ ManufacturerPartNumber = part . ManufacturerPartNumber ,
368
+ Manufacturer = part . Manufacturer ,
369
+ Description = part . Description ,
370
+ ImageUrl = part . ImagePath ,
371
+ DatasheetUrls = new List < string > { part . DataSheetUrl ?? string . Empty } ,
372
+ ProductUrl = part . ProductDetailUrl ,
373
+ Status = part . LifecycleStatus ,
374
+ Currency = mouserOrderResponse . CurrencyCode ,
375
+ AdditionalPartNumbers = new List < string > ( ) ,
376
+ BasePartNumber = part . ManufacturerPartNumber ,
377
+ MountingTypeId = 0 ,
378
+ PackageType = "" ,
379
+ Cost = lineItem . UnitPrice ,
380
+ QuantityAvailable = lineItem . Quantity ,
381
+ Reference = lineItem . CartItemCustPartNumber ,
382
+ } ) ;
383
+ }
380
384
}
381
385
}
386
+ else
387
+ {
388
+ // use the more minimal information provided by the order import call
389
+ commonParts . Add ( new CommonPart
390
+ {
391
+ SupplierPartNumber = lineItem . MouserPartNumber ,
392
+ Supplier = "Mouser" ,
393
+ ManufacturerPartNumber = lineItem . MfrPartNumber ,
394
+ Manufacturer = lineItem . Manufacturer ,
395
+ Description = lineItem . Description ,
396
+ //ImageUrl = part.ImagePath,
397
+ //DatasheetUrls = new List<string> { part.DataSheetUrl ?? string.Empty },
398
+ //ProductUrl = lineItem.ProductDetailUrl,
399
+ //Status = part.LifecycleStatus,
400
+ Currency = mouserOrderResponse . CurrencyCode ,
401
+ AdditionalPartNumbers = new List < string > ( ) ,
402
+ BasePartNumber = lineItem . MfrPartNumber ,
403
+ MountingTypeId = 0 ,
404
+ PackageType = "" ,
405
+ Cost = lineItem . UnitPrice ,
406
+ QuantityAvailable = lineItem . Quantity ,
407
+ Reference = lineItem . CartItemCustPartNumber ,
408
+ } ) ;
409
+ }
382
410
}
383
411
384
412
foreach ( var part in commonParts )
0 commit comments