public ActionResult ExportCustomersExcelNebim() { try { var registeredCustomers = _customerService.GetAllCustomers(null, null, new int[] { 1, 2, 3 }, null, null, null, null, 0, 0, false, null, 0, int.MaxValue); var allOrders = _orderService.LoadAllOrders(); var unregisteredOrders = allOrders.Where(x => (x.Customer.IsGuest() && !x.Customer.IsRegistered())); var unregisterdCustomers = unregisteredOrders.Select(x => x.Customer).ToList(); var customers = registeredCustomers.Union(unregisterdCustomers).ToList(); string fileName = string.Format("customers_{0}_{1}.xlsx", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"), CommonHelper.GenerateRandomDigitCode(4)); string filePath = string.Format("{0}content\\files\\ExportImport\\{1}", Request.PhysicalApplicationPath, fileName); _exportManager.ExportCustomersToXlsxForNebim(filePath, customers); var bytes = System.IO.File.ReadAllBytes(filePath); return(File(bytes, "text/xls", fileName)); } catch (Exception exc) { ErrorNotification(exc); return(RedirectToAction("List")); } }