public async Task <IActionResult> ExportXlsx() { try { var bytes = _exportManager.ExportManufacturersToXlsx(await _manufacturerService.GetAllManufacturers(showHidden: true, storeId: _workContext.CurrentCustomer.StaffStoreId)); return(File(bytes, "text/xls", "manufacturers.xlsx")); } catch (Exception exc) { ErrorNotification(exc); return(RedirectToAction("List")); } }
public IActionResult ExportXlsx() { try { var bytes = _exportManager.ExportManufacturersToXlsx(_manufacturerService.GetAllManufacturers(showHidden: true)); return(File(bytes, "text/xls", "manufacturers.xlsx")); } catch (Exception exc) { ErrorNotification(exc); return(RedirectToAction("List")); } }
public IActionResult ExportXlsx() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageManufacturers)) { return(AccessDeniedView()); } try { var bytes = _exportManager.ExportManufacturersToXlsx(_manufacturerService.GetAllManufacturers(showHidden: true)); return(File(bytes, "text/xls", "manufacturers.xlsx")); } catch (Exception exc) { ErrorNotification(exc); return(RedirectToAction("List")); } }
public virtual IActionResult ExportXlsx() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageManufacturers)) { return(AccessDeniedView()); } try { var bytes = _exportManager.ExportManufacturersToXlsx(_manufacturerService.GetAllManufacturers(showHidden: true).Where(p => !p.Deleted)); return(File(bytes, MimeTypes.TextXlsx, "manufacturers.xlsx")); } catch (Exception exc) { _notificationService.ErrorNotification(exc); return(RedirectToAction("List")); } }
public void CanExportManufacturersXlsx() { var manufacturers = _manufacturerService.GetAllManufacturers(); var excelData = _exportManager.ExportManufacturersToXlsx(manufacturers); var worksheet = GetWorksheets(excelData); var manager = GetPropertyManager <Manufacturer>(worksheet); manager.ReadFromXlsx(worksheet, 2); var manufacturer = manufacturers.First(); var ignore = new List <string> { "Picture", "EntityCacheKey", "PictureId", "SubjectToAcl", "LimitedToStores", "Deleted", "CreatedOnUtc", "UpdatedOnUtc", "AppliedDiscounts", "DiscountManufacturerMappings" }; AreAllObjectPropertiesPresent(manufacturer, manager, ignore.ToArray()); PropertiesShouldEqual(manufacturer, manager, new Dictionary <string, string>()); manager.GetProperties.First(p => p.PropertyName == "Picture").PropertyValue.Should().NotBeNull(); }
public void Can_export_manufacturers_xlsx() { var manufacturers = new List <Manufacturer> { new Manufacturer { Id = 1, Name = "TestManufacturer", Description = "TestDescription", ManufacturerTemplateId = 1, MetaKeywords = "MetaKeywords", MetaDescription = "MetaDescription", MetaTitle = "MetaTitle", PictureId = 1, PageSize = 15, AllowCustomersToSelectPageSize = true, PageSizeOptions = "5,10,15", PriceRanges = string.Empty, Published = true, DisplayOrder = 1 } }; var excelData = _exportManager.ExportManufacturersToXlsx(manufacturers); var worksheet = GetWorksheets(excelData); var manager = GetPropertyManager <Manufacturer>(worksheet); manager.ReadFromXlsx(worksheet, 2); var manufacturer = manufacturers.First(); var ignore = new List <string> { "Picture", "PictureId", "SubjectToAcl", "LimitedToStores", "Deleted", "CreatedOnUtc", "UpdatedOnUtc", "AppliedDiscounts", "DiscountManufacturerMappings" }; AreAllObjectPropertiesPresent(manufacturer, manager, ignore.ToArray()); PropertiesShouldEqual(manufacturer, manager, new Dictionary <string, string>()); manager.GetProperties.First(p => p.PropertyName == "Picture").PropertyValue.ShouldEqual(@"c:\temp\picture.png"); }
/// <summary> /// Export manufacturers to XLSX /// </summary> /// <param name="manufacturers">Manufactures</param> public byte[] ExportManufacturersToXlsx(IEnumerable <Manufacturer> manufacturers) { return(_exportManager.ExportManufacturersToXlsx(manufacturers)); }