Ejemplo n.º 1
0
        public virtual IActionResult ExportExcelAll(ConsignmentOrderSearchModel searchModel)
        {
            if (!permissionService.Authorize(StandardPermissionProvider.ManageConsignmentOrders))
            {
                return(AccessDeniedView());
            }

            var list = consignmentOrderService.GetAll(
                shipmentMethod: searchModel.SearchShipmentMethod,
                startPoint: searchModel.SearchStartPoint,
                terminal: searchModel.SearchTerminal,
                consignor: searchModel.SearchConsignor,
                consignee: searchModel.SearchConsignee,
                tripId: searchModel.TripId,
                noRelatedTrip: searchModel.SearchNoRelatedTrip,
                serialNum: searchModel.SearchSerialNum,
                consignmentTimeFrom: searchModel.SearchConsignmentTimeFrom,
                consignmentTimeTo: searchModel.SearchConsignmentTimeTo,
                orderStatuses: (searchModel.SearchOrderStatuses?.Contains(0) ?? false) ? null : searchModel.SearchOrderStatuses,
                paymentStatuses: (searchModel.SearchPaymentStatuses?.Contains(0) ?? false) ? null : searchModel.SearchPaymentStatuses);

            try
            {
                var bytes = exportManager.ExportConsignmentOrdersToXlsx(list);

                return(File(bytes, MimeTypes.TextXlsx, $"{localizationService.GetResource("Admin.Logistics.ConsignmentOrder")}.xlsx"));
            }
            catch (Exception ex)
            {
                ErrorNotification(ex);
                return(RedirectToAction("List"));
            }
        }