Пример #1
0
 public IHttpActionResult DownloadSummaryDiscountProductReport([FromUri] OrderAdminSearchCriteria searchCriteria)
 {
     try
     {
         var    path = System.Web.Hosting.HostingEnvironment.MapPath(_appSettings.SummaryDiscountProductTemplate);
         byte[] content;
         var    isWarehouse = _workContext.User.IsInRole(UserRole.Warehouse);
         using (FileStream file = File.Open(path, FileMode.Open))
         {
             content = _orderReportService.GetSummaryDiscountProductReport(
                 _workContext.User,
                 file,
                 searchCriteria);
         }
         var stream = new MemoryStream(content);
         var result = new FileActionResult(stream,
                                           $"SummaryDiscountProduct_{searchCriteria.OrderStatus}_{DateTime.Now.ToString("dd-MM-yyyy")}.xlsx");
         return(result);
     }
     catch (StaffingPurchaseException ex)
     {
         return(new StaffPurchaseExceptionActionResult(ex.Message));
     }
     catch (Exception ex)
     {
         _logger.Error("Failed to download Summary Discount Product Report", ex);
         return(new StaffPurchaseExceptionActionResult(_resourceManager.GetString("OrderReport.FailedToReport")));
     }
 }