public void can_export_categories_to_xlsx()
        {
            var categories = new List <Category>
            {
                new Category
                {
                    Id                  = 1,
                    CategoryName        = "TestCategory",
                    CategoryDescription = "TestDescription",
                    DisplayOrder        = 1
                }
            };

            var excelData = _exportManager.ExportCategoriesToXlsx(categories);
            var worksheet = GetWorksheets(excelData);
            var manager   = GetPropertyManager <Category>(worksheet);

            manager.ReadFromXlsx(worksheet, 2);
            var category = categories.First();

            var ignore = new List <string> {
                "CreatedOnUtc", "Picture", "PictureId", "AppliedDiscounts", "UpdatedOnUtc", "SubjectToAcl", "LimitedToStores", "Deleted"
            };

            AreAllObjectPropertiesPresent(category, manager, ignore.ToArray());
            PropertiesShouldEqual(category, manager, new Dictionary <string, string>());

            manager.GetProperties.First(p => p.PropertyName == "Picture").PropertyValue.ShouldEqual(@"c:\temp\picture.png");
        }
Esempio n. 2
0
 public async Task <IActionResult> ExportXlsx()
 {
     try
     {
         var bytes = _exportManager.ExportCategoriesToXlsx(await _categoryService.GetAllCategories(showHidden: true, storeId: _workContext.CurrentCustomer.StaffStoreId));
         return(File(bytes, "text/xls", "categories.xlsx"));
     }
     catch (Exception exc)
     {
         ErrorNotification(exc);
         return(RedirectToAction("List"));
     }
 }
        public IActionResult ExportXlsx()
        {
            try
            {
                var bytes = _exportManager.ExportCategoriesToXlsx(_categoryService.GetAllCategories(showHidden: true));

                return(File(bytes, "text/xls", "categories.xlsx"));
            }
            catch (Exception exc)
            {
                ErrorNotification(exc);
                return(RedirectToAction("List"));
            }
        }
Esempio n. 4
0
        public virtual IActionResult ExportXlsx()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories))
            {
                return(AccessDeniedView());
            }

            try
            {
                var bytes = _exportManager.ExportCategoriesToXlsx(_categoryService.GetAllCategories(showHidden: true, loadCacheableCopy: false).ToList());
                return(File(bytes, MimeTypes.TextXlsx, "categories.xlsx"));
            }
            catch (Exception exc)
            {
                ErrorNotification(exc);
                return(RedirectToAction("List"));
            }
        }
Esempio n. 5
0
        public ActionResult ExportXlsx()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories))
            {
                return(AccessDeniedView());
            }

            try
            {
                var bytes = _exportManager.ExportCategoriesToXlsx(_categoryService.GetAllCategories(showHidden: true).Where(p => !p.Deleted));

                return(File(bytes, "text/xls", "categories.xlsx"));
            }
            catch (Exception exc)
            {
                ErrorNotification(exc);
                return(RedirectToAction("List"));
            }
        }
Esempio n. 6
0
        public void Can_export_categories_to_xlsx()
        {
            var categories = new List <Category>
            {
                new Category
                {
                    Id                             = 1,
                    Name                           = "TestCategory",
                    Description                    = "TestDescription",
                    CategoryTemplateId             = 1,
                    MetaKeywords                   = "TestMetaKeywords",
                    MetaDescription                = "TestMetaDescription",
                    MetaTitle                      = "TestMetaTitle",
                    ParentCategoryId               = 0,
                    PictureId                      = 1,
                    PageSize                       = 10,
                    AllowCustomersToSelectPageSize = true,
                    PageSizeOptions                = "10;20;30",
                    PriceRanges                    = "100;200;300",
                    ShowOnHomePage                 = true,
                    IncludeInTopMenu               = true,
                    Published                      = true,
                    DisplayOrder                   = 1
                }
            };

            var excelData = _exportManager.ExportCategoriesToXlsx(categories);
            var worksheet = GetWorksheets(excelData);
            var manager   = GetPropertyManager <Category>(worksheet);

            manager.ReadFromXlsx(worksheet, 2);
            var category = categories.First();

            var ignore = new List <string> {
                "CreatedOnUtc", "Picture", "PictureId", "AppliedDiscounts", "UpdatedOnUtc", "SubjectToAcl", "LimitedToStores", "Deleted", "DiscountCategoryMappings"
            };

            AreAllObjectPropertiesPresent(category, manager, ignore.ToArray());
            PropertiesShouldEqual(category, manager, new Dictionary <string, string>());

            manager.GetProperties.First(p => p.PropertyName == "Picture").PropertyValue.ShouldEqual(@"c:\temp\picture.png");
        }
Esempio n. 7
0
        public void CanExportCategoriesToXlsx()
        {
            var categories = _categoryService.GetAllCategories();

            var excelData = _exportManager.ExportCategoriesToXlsx(categories);
            var worksheet = GetWorksheets(excelData);
            var manager   = GetPropertyManager <Category>(worksheet);

            manager.ReadFromXlsx(worksheet, 2);
            var category = categories.First();

            var ignore = new List <string> {
                "CreatedOnUtc", "EntityCacheKey", "Picture", "PictureId", "AppliedDiscounts", "UpdatedOnUtc", "SubjectToAcl", "LimitedToStores", "Deleted", "DiscountCategoryMappings"
            };

            AreAllObjectPropertiesPresent(category, manager, ignore.ToArray());
            PropertiesShouldEqual(category, manager, new Dictionary <string, string>());

            manager.GetProperties.First(p => p.PropertyName == "Picture").PropertyValue.Should().NotBeNull();
        }
Esempio n. 8
0
 /// <summary>
 /// Export categories to XLSX
 /// </summary>
 /// <param name="categories">Categories</param>
 public byte[] ExportCategoriesToXlsx(IEnumerable <Category> categories)
 {
     return(_exportManager.ExportCategoriesToXlsx(categories));
 }