public void can_export_customers_to_xlsx()
        {
            var customers = new List <Customer>
            {
                new Customer
                {
                    Active       = true,
                    AffiliateId  = 0,
                    CreatedOnUtc = new DateTime(2010, 01, 04),
                    CustomerGuid = Guid.NewGuid(),
                    Email        = "*****@*****.**",
                    Username     = "******",
                    IsTaxExempt  = true,
                    VendorId     = 0
                }
            };

            var excelData = _exportManager.ExportCustomersToXlsx(customers);
            var worksheet = GetWorksheets(excelData);
            var manager   = GetPropertyManager <Customer>(worksheet);

            manager.ReadFromXlsx(worksheet, 2);
            var customer = customers.First();

            var ignore = new List <string> {
                "Id", "ExternalAuthenticationRecords", "CustomerRoles", "ShoppingCartItems",
                "ReturnRequests", "BillingAddress", "ShippingAddress", "Addresses", "AdminComment",
                "EmailToRevalidate", "HasShoppingCartItems", "RequireReLogin", "FailedLoginAttempts",
                "CannotLoginUntilDateUtc", "Deleted", "IsSystemAccount", "SystemName", "LastIpAddress",
                "LastLoginDateUtc", "LastActivityDateUtc", "RegisteredInStoreId"
            };

            AreAllObjectPropertiesPresent(customer, manager, ignore.ToArray());
            PropertiesShouldEqual(customer, manager, new Dictionary <string, string>());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> ExportExcelAll(CustomerListModel model)
        {
            var customers = await _customerService.GetAllCustomers(
                customerRoleIds : model.SearchCustomerRoleIds.ToArray(),
                email : model.SearchEmail,
                username : model.SearchUsername,
                firstName : model.SearchFirstName,
                lastName : model.SearchLastName,
                company : model.SearchCompany,
                phone : model.SearchPhone,
                zipPostalCode : model.SearchZipPostalCode,
                loadOnlyWithShoppingCart : false);

            try
            {
                byte[] bytes = _exportManager.ExportCustomersToXlsx(customers);
                return(File(bytes, "text/xls", "customers.xlsx"));
            }
            catch (Exception exc)
            {
                ErrorNotification(exc);
                return(RedirectToAction("List"));
            }
        }
Ejemplo n.º 3
0
        public void CanExportCustomersToXlsx()
        {
            var customers = _customerService.GetAllCustomers();

            var excelData = _exportManager.ExportCustomersToXlsx(customers);
            var worksheet = GetWorksheets(excelData);
            var manager   = GetPropertyManager <Customer>(worksheet);

            manager.ReadFromXlsx(worksheet, 2);
            var customer = customers.First();

            var ignore = new List <string> {
                "Id", "ExternalAuthenticationRecords", "CustomerRoles", "ShoppingCartItems",
                "ReturnRequests", "BillingAddress", "ShippingAddress", "Addresses", "AdminComment",
                "EmailToRevalidate", "HasShoppingCartItems", "RequireReLogin", "FailedLoginAttempts",
                "CannotLoginUntilDateUtc", "Deleted", "IsSystemAccount", "SystemName", "LastIpAddress",
                "LastLoginDateUtc", "LastActivityDateUtc", "RegisteredInStoreId", "BillingAddressId", "ShippingAddressId",
                "CustomerCustomerRoleMappings", "CustomerAddressMappings", "EntityCacheKey"
            };

            AreAllObjectPropertiesPresent(customer, manager, ignore.ToArray());
            PropertiesShouldEqual(customer, manager, new Dictionary <string, string>());
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Export customer list to XLSX
 /// </summary>
 /// <param name="customers">Customers</param>
 public byte[] ExportCustomersToXlsx(IList <Customer> customers)
 {
     return(_exportManager.ExportCustomersToXlsx(customers));
 }