public IActionResult ExportXml() { try { var manufacturers = _manufacturerService.GetAllManufacturers(showHidden: true); var xml = _exportManager.ExportManufacturersToXml(manufacturers); return(File(Encoding.UTF8.GetBytes(xml), "application/xml", "manufacturers.xml")); } catch (Exception exc) { ErrorNotification(exc); return(RedirectToAction("List")); } }
public async Task <IActionResult> ExportXml() { try { var manufacturers = await _manufacturerService.GetAllManufacturers(showHidden : true, storeId : _workContext.CurrentCustomer.StaffStoreId); var xml = await _exportManager.ExportManufacturersToXml(manufacturers); return(File(Encoding.UTF8.GetBytes(xml), "application/xml", "manufacturers.xml")); } catch (Exception exc) { ErrorNotification(exc); return(RedirectToAction("List")); } }
public void Can_export_manufacturers_to_xml() { var manufacturers = new List <Manufacturer>() { new Manufacturer() { Id = 1, Name = "Name", Description = "Description 1", MetaKeywords = "Meta keywords", MetaDescription = "Meta description", MetaTitle = "Meta title", SeName = "SE name", PictureId = 0, PageSize = 4, PriceRanges = "1-3;", Published = true, Deleted = false, DisplayOrder = 5, CreatedOnUtc = new DateTime(2010, 01, 01), UpdatedOnUtc = new DateTime(2010, 01, 02), }, new Manufacturer() { Id = 2, Name = "Name 2", Description = "Description 2", MetaKeywords = "Meta keywords", MetaDescription = "Meta description", MetaTitle = "Meta title", SeName = "SE name", PictureId = 0, PageSize = 4, PriceRanges = "1-3;", Published = true, Deleted = false, DisplayOrder = 5, CreatedOnUtc = new DateTime(2010, 01, 01), UpdatedOnUtc = new DateTime(2010, 01, 02), } }; string result = _exportManager.ExportManufacturersToXml(manufacturers); //TODO test it String.IsNullOrEmpty(result).ShouldBeFalse(); }
public ActionResult ExportXml() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog)) { return(AccessDeniedView()); } try { var manufacturers = _manufacturerService.GetAllManufacturers(true); var xml = _exportManager.ExportManufacturersToXml(manufacturers); return(new XmlDownloadResult(xml, "manufacturers.xml")); } catch (Exception exc) { ErrorNotification(exc); return(RedirectToAction("List")); } }
public virtual IActionResult ExportXml() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageManufacturers)) { return(AccessDeniedView()); } try { var manufacturers = _manufacturerService.GetAllManufacturers(showHidden: true); var xml = _exportManager.ExportManufacturersToXml(manufacturers); return(File(Encoding.UTF8.GetBytes(xml), "application/xml", "manufacturers.xml")); } catch (Exception exc) { _notificationService.ErrorNotification(exc); return(RedirectToAction("List")); } }
public ActionResult ExportXml() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog)) { return(AccessDeniedView()); } try { var fileName = string.Format("manufacturers_{0}.xml", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")); var manufacturers = _manufacturerService.GetAllManufacturers(true); var xml = _exportManager.ExportManufacturersToXml(manufacturers); return(new XmlDownloadResult(xml, fileName)); } catch (Exception exc) { ErrorNotification(exc); return(RedirectToAction("List")); } }
/// <summary> /// Export manufacturer list to xml /// </summary> /// <param name="manufacturers">Manufacturers</param> /// <returns>Result in XML format</returns> public string ExportManufacturersToXml(IList <Manufacturer> manufacturers) { return(_exportManager.ExportManufacturersToXml(manufacturers)); }