@@ -357,14 +357,13 @@ public virtual IActionResult ExportXmlAll(OrderSearchModel model)
357
357
//ensure that we at least one order selected
358
358
if ( ! orders . Any ( ) )
359
359
{
360
- _notificationService . ErrorNotification ( _localizationService . GetResource ( "Admin.Orders.PdfInvoice. NoOrders" ) ) ;
360
+ _notificationService . ErrorNotification ( _localizationService . GetResource ( "Admin.Orders.NoOrders" ) ) ;
361
361
return RedirectToAction ( "List" ) ;
362
362
}
363
363
364
364
try
365
365
{
366
366
var xml = _exportManager . ExportOrdersToXml ( orders ) ;
367
-
368
367
return File ( Encoding . UTF8 . GetBytes ( xml ) , MimeTypes . ApplicationXml , "orders.xml" ) ;
369
368
}
370
369
catch ( Exception exc )
@@ -390,16 +389,16 @@ public virtual IActionResult ExportXmlSelected(string selectedIds)
390
389
orders . AddRange ( _orderService . GetOrdersByIds ( ids ) . Where ( HasAccessToOrder ) ) ;
391
390
}
392
391
393
- //ensure that we at least one order selected
394
- if ( ! orders . Any ( ) )
392
+ try
393
+ {
394
+ var xml = _exportManager . ExportOrdersToXml ( orders ) ;
395
+ return File ( Encoding . UTF8 . GetBytes ( xml ) , MimeTypes . ApplicationXml , "orders.xml" ) ;
396
+ }
397
+ catch ( Exception exc )
395
398
{
396
- _notificationService . ErrorNotification ( _localizationService . GetResource ( "Admin.Orders.PdfInvoice.NoOrders" ) ) ;
399
+ _notificationService . ErrorNotification ( exc ) ;
397
400
return RedirectToAction ( "List" ) ;
398
401
}
399
-
400
- var xml = _exportManager . ExportOrdersToXml ( orders ) ;
401
-
402
- return File ( Encoding . UTF8 . GetBytes ( xml ) , MimeTypes . ApplicationXml , "orders.xml" ) ;
403
402
}
404
403
405
404
[ HttpPost , ActionName ( "ExportExcel" ) ]
@@ -456,7 +455,7 @@ public virtual IActionResult ExportExcelAll(OrderSearchModel model)
456
455
//ensure that we at least one order selected
457
456
if ( ! orders . Any ( ) )
458
457
{
459
- _notificationService . ErrorNotification ( _localizationService . GetResource ( "Admin.Orders.PdfInvoice. NoOrders" ) ) ;
458
+ _notificationService . ErrorNotification ( _localizationService . GetResource ( "Admin.Orders.NoOrders" ) ) ;
460
459
return RedirectToAction ( "List" ) ;
461
460
}
462
461
@@ -488,13 +487,6 @@ public virtual IActionResult ExportExcelSelected(string selectedIds)
488
487
orders . AddRange ( _orderService . GetOrdersByIds ( ids ) . Where ( HasAccessToOrder ) ) ;
489
488
}
490
489
491
- //ensure that we at least one order selected
492
- if ( ! orders . Any ( ) )
493
- {
494
- _notificationService . ErrorNotification ( _localizationService . GetResource ( "Admin.Orders.PdfInvoice.NoOrders" ) ) ;
495
- return RedirectToAction ( "List" ) ;
496
- }
497
-
498
490
try
499
491
{
500
492
var bytes = _exportManager . ExportOrdersToXlsx ( orders ) ;
@@ -1034,18 +1026,26 @@ public virtual IActionResult PdfInvoiceAll(OrderSearchModel model)
1034
1026
//ensure that we at least one order selected
1035
1027
if ( ! orders . Any ( ) )
1036
1028
{
1037
- _notificationService . ErrorNotification ( _localizationService . GetResource ( "Admin.Orders.PdfInvoice. NoOrders" ) ) ;
1029
+ _notificationService . ErrorNotification ( _localizationService . GetResource ( "Admin.Orders.NoOrders" ) ) ;
1038
1030
return RedirectToAction ( "List" ) ;
1039
1031
}
1040
1032
1041
- byte [ ] bytes ;
1042
- using ( var stream = new MemoryStream ( ) )
1033
+ try
1043
1034
{
1044
- _pdfService . PrintOrdersToPdf ( stream , orders , _orderSettings . GeneratePdfInvoiceInCustomerLanguage ? 0 : _workContext . WorkingLanguage . Id , model . VendorId ) ;
1045
- bytes = stream . ToArray ( ) ;
1046
- }
1035
+ byte [ ] bytes ;
1036
+ using ( var stream = new MemoryStream ( ) )
1037
+ {
1038
+ _pdfService . PrintOrdersToPdf ( stream , orders , _orderSettings . GeneratePdfInvoiceInCustomerLanguage ? 0 : _workContext . WorkingLanguage . Id , model . VendorId ) ;
1039
+ bytes = stream . ToArray ( ) ;
1040
+ }
1047
1041
1048
- return File ( bytes , MimeTypes . ApplicationPdf , "orders.pdf" ) ;
1042
+ return File ( bytes , MimeTypes . ApplicationPdf , "orders.pdf" ) ;
1043
+ }
1044
+ catch ( Exception exc )
1045
+ {
1046
+ _notificationService . ErrorNotification ( exc ) ;
1047
+ return RedirectToAction ( "List" ) ;
1048
+ }
1049
1049
}
1050
1050
1051
1051
[ HttpPost ]
@@ -1072,21 +1072,22 @@ public virtual IActionResult PdfInvoiceSelected(string selectedIds)
1072
1072
vendorId = _workContext . CurrentVendor . Id ;
1073
1073
}
1074
1074
1075
- //ensure that we at least one order selected
1076
- if ( ! orders . Any ( ) )
1075
+ try
1077
1076
{
1078
- _notificationService . ErrorNotification ( _localizationService . GetResource ( "Admin.Orders.PdfInvoice.NoOrders" ) ) ;
1079
- return RedirectToAction ( "List" ) ;
1080
- }
1077
+ byte [ ] bytes ;
1078
+ using ( var stream = new MemoryStream ( ) )
1079
+ {
1080
+ _pdfService . PrintOrdersToPdf ( stream , orders , _orderSettings . GeneratePdfInvoiceInCustomerLanguage ? 0 : _workContext . WorkingLanguage . Id , vendorId ) ;
1081
+ bytes = stream . ToArray ( ) ;
1082
+ }
1081
1083
1082
- byte [ ] bytes ;
1083
- using ( var stream = new MemoryStream ( ) )
1084
+ return File ( bytes , MimeTypes . ApplicationPdf , "orders.pdf" ) ;
1085
+ }
1086
+ catch ( Exception exc )
1084
1087
{
1085
- _pdfService . PrintOrdersToPdf ( stream , orders , _orderSettings . GeneratePdfInvoiceInCustomerLanguage ? 0 : _workContext . WorkingLanguage . Id , vendorId ) ;
1086
- bytes = stream . ToArray ( ) ;
1088
+ _notificationService . ErrorNotification ( exc ) ;
1089
+ return RedirectToAction ( "List" ) ;
1087
1090
}
1088
-
1089
- return File ( bytes , MimeTypes . ApplicationPdf , "orders.pdf" ) ;
1090
1091
}
1091
1092
1092
1093
//currently we use this method on the add product to order details pages
@@ -2469,14 +2470,22 @@ public virtual IActionResult PdfPackagingSlipAll(ShipmentSearchModel model)
2469
2470
return RedirectToAction ( "ShipmentList" ) ;
2470
2471
}
2471
2472
2472
- byte [ ] bytes ;
2473
- using ( var stream = new MemoryStream ( ) )
2473
+ try
2474
2474
{
2475
- _pdfService . PrintPackagingSlipsToPdf ( stream , shipments , _orderSettings . GeneratePdfInvoiceInCustomerLanguage ? 0 : _workContext . WorkingLanguage . Id ) ;
2476
- bytes = stream . ToArray ( ) ;
2477
- }
2475
+ byte [ ] bytes ;
2476
+ using ( var stream = new MemoryStream ( ) )
2477
+ {
2478
+ _pdfService . PrintPackagingSlipsToPdf ( stream , shipments , _orderSettings . GeneratePdfInvoiceInCustomerLanguage ? 0 : _workContext . WorkingLanguage . Id ) ;
2479
+ bytes = stream . ToArray ( ) ;
2480
+ }
2478
2481
2479
- return File ( bytes , MimeTypes . ApplicationPdf , "packagingslips.pdf" ) ;
2482
+ return File ( bytes , MimeTypes . ApplicationPdf , "packagingslips.pdf" ) ;
2483
+ }
2484
+ catch ( Exception exc )
2485
+ {
2486
+ _notificationService . ErrorNotification ( exc ) ;
2487
+ return RedirectToAction ( "ShipmentList" ) ;
2488
+ }
2480
2489
}
2481
2490
2482
2491
[ HttpPost ]
@@ -2500,21 +2509,22 @@ public virtual IActionResult PdfPackagingSlipSelected(string selectedIds)
2500
2509
shipments = shipments . Where ( HasAccessToShipment ) . ToList ( ) ;
2501
2510
}
2502
2511
2503
- //ensure that we at least one shipment selected
2504
- if ( ! shipments . Any ( ) )
2512
+ try
2505
2513
{
2506
- _notificationService . ErrorNotification ( _localizationService . GetResource ( "Admin.Orders.Shipments.NoShipmentsSelected" ) ) ;
2507
- return RedirectToAction ( "ShipmentList" ) ;
2508
- }
2514
+ byte [ ] bytes ;
2515
+ using ( var stream = new MemoryStream ( ) )
2516
+ {
2517
+ _pdfService . PrintPackagingSlipsToPdf ( stream , shipments , _orderSettings . GeneratePdfInvoiceInCustomerLanguage ? 0 : _workContext . WorkingLanguage . Id ) ;
2518
+ bytes = stream . ToArray ( ) ;
2519
+ }
2509
2520
2510
- byte [ ] bytes ;
2511
- using ( var stream = new MemoryStream ( ) )
2521
+ return File ( bytes , MimeTypes . ApplicationPdf , "packagingslips.pdf" ) ;
2522
+ }
2523
+ catch ( Exception exc )
2512
2524
{
2513
- _pdfService . PrintPackagingSlipsToPdf ( stream , shipments , _orderSettings . GeneratePdfInvoiceInCustomerLanguage ? 0 : _workContext . WorkingLanguage . Id ) ;
2514
- bytes = stream . ToArray ( ) ;
2525
+ _notificationService . ErrorNotification ( exc ) ;
2526
+ return RedirectToAction ( "ShipmentList" ) ;
2515
2527
}
2516
-
2517
- return File ( bytes , MimeTypes . ApplicationPdf , "packagingslips.pdf" ) ;
2518
2528
}
2519
2529
2520
2530
[ HttpPost ]
0 commit comments