Hi All,
I am trying to create a export packing slips feature for v2.3 on the orders list page in admin area, I need to pass the list of orders which are a result of orderSearch.
I am getting stuck at the part where I need to pass the model parameter to the action method.
Inside List.cshtml:
<a href="@Url.Action("PdfPackagingSlips", ???)" class="t-button">Print Packing Slips</a>
Inside Orders controller:
public ActionResult PdfPackagingSlips(OrderListModel model)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageOrders))
return AccessDeniedView();
DateTime? startDateValue = (model.StartDate == null) ? null
: (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.StartDate.Value, _dateTimeHelper.CurrentTimeZone);
DateTime? endDateValue = (model.EndDate == null) ? null
: (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.EndDate.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1);
OrderStatus? orderStatus = model.OrderStatusId > 0 ? (OrderStatus?)(model.OrderStatusId) : null;
PaymentStatus? paymentStatus = model.PaymentStatusId > 0 ? (PaymentStatus?)(model.PaymentStatusId) : null;
ShippingStatus? shippingStatus = model.ShippingStatusId > 0 ? (ShippingStatus?)(model.ShippingStatusId) : null;
var orders = _orderService.SearchOrders(startDateValue, endDateValue, orderStatus,
paymentStatus, shippingStatus, model.CustomerEmail, model.OrderGuid, 0, 10000);
var orderList = new List<Order>();
foreach(Order order in orders){
orderList.Add(order);
}
string fileName = string.Format("packagingslip_{0}_{1}.pdf", "", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"));
string filePath = string.Format("{0}content\\files\\ExportImport\\{1}", this.Request.PhysicalApplicationPath, fileName);
_pdfService.PrintPackagingSlipsToPdf(orderList, filePath);
var bytes = System.IO.File.ReadAllBytes(filePath);
return File(bytes, "application/pdf", fileName);
}
....
Please help me if I have lost my way... Appreciate your support.
Thanks.