Beispiel #1
0
        /// <returns>A task that represents the asynchronous operation</returns>
        public virtual async Task <IActionResult> ExportXml(int id)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageLanguages))
            {
                return(AccessDeniedView());
            }

            //try to get a language with the specified id
            var language = await _languageService.GetLanguageByIdAsync(id);

            if (language == null)
            {
                return(RedirectToAction("List"));
            }

            try
            {
                var xml = await _localizationService.ExportResourcesToXmlAsync(language);

                return(File(Encoding.UTF8.GetBytes(xml), "application/xml", "language_pack.xml"));
            }
            catch (Exception exc)
            {
                await _notificationService.ErrorNotificationAsync(exc);

                return(RedirectToAction("List"));
            }
        }
        public virtual async Task <ActionResult> ExportResources(int langId)
        {
            var language = await LanguagesService.FindByIdAsync(langId);

            if (language == null)
            {
                return(RedirectToAction("PageNotFound", "Error"));
            }

            var xmlString = await _localizationService.ExportResourcesToXmlAsync(language);

            var contentType = "text/xml";
            var bytes       = Encoding.UTF8.GetBytes(xmlString);
            var result      = new FileContentResult(bytes, contentType);

            result.FileDownloadName = $"DigiCommerce.StringResources.{language.IsoCode}.xml";

            return(result);
        }