Example #1
0
        public async Task <IActionResult> ImportFromXlsx(IFormFile importexcelfile, [FromServices] IWorkContext workContext)
        {
            //a vendor and staff cannot import collections
            if (workContext.CurrentVendor != null || await _groupService.IsStaff(_workContext.CurrentCustomer))
            {
                return(AccessDeniedView());
            }

            try
            {
                if (importexcelfile != null && importexcelfile.Length > 0)
                {
                    await _importManager.ImportBrandFromXlsx(importexcelfile.OpenReadStream());
                }
                else
                {
                    Error(_translationService.GetResource("Admin.Common.UploadFile"));
                    return(RedirectToAction("List"));
                }
                Success(_translationService.GetResource("Admin.Catalog.Brands.Imported"));
                return(RedirectToAction("List"));
            }
            catch (Exception exc)
            {
                Error(exc);
                return(RedirectToAction("List"));
            }
        }