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"); }
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")); } }
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")); } }
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")); } }
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"); }
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(); }
/// <summary> /// Export categories to XLSX /// </summary> /// <param name="categories">Categories</param> public byte[] ExportCategoriesToXlsx(IEnumerable <Category> categories) { return(_exportManager.ExportCategoriesToXlsx(categories)); }