public FileUploadJsonResult ImportRedirects(HttpPostedFileBase xmlfile) { CheckAccess(); if (!IsXml(xmlfile)) { return(new FileUploadJsonResult { Data = new { message = LocalizationService.Current.GetString("/gadget/redirects/invalidxmlfile") } }); } // Read all redirects from xml file RedirectsXmlParser parser = new RedirectsXmlParser(xmlfile.InputStream); // Save all redirects from xml file CustomRedirectCollection redirects = parser.Load(); string message; if (redirects != null || redirects.Count() != 0) { _redirectsService.AddOrUpdate(redirects); CustomRedirectHandler.ClearCache(); message = string.Format(LocalizationService.Current.GetString("/gadget/redirects/importsuccess"), redirects.Count()); } else { message = LocalizationService.Current.GetString("/gadget/redirects/importnone"); } return(new FileUploadJsonResult { Data = new { message = message } }); }
public XmlActionResult ExportAllRedirects() { CheckAccess(); var redirects = _redirectsService.GetSaved().ToList(); XmlDocument document = new RedirectsXmlParser().Export(redirects); return(new XmlActionResult(document)); }
public XmlActionResult ExportAllRedirects() { CheckAccess(); DataStoreHandler dsHandler = new DataStoreHandler(); List <CustomRedirect> redirects = dsHandler.GetCustomRedirects(true); XmlDocument document = new RedirectsXmlParser().Export(redirects); return(new XmlActionResult(document)); }
public FileUploadJsonResult ImportRedirects(HttpPostedFileBase xmlfile) { CheckAccess(); // Read all redirects from xml file RedirectsXmlParser parser = new RedirectsXmlParser(xmlfile.InputStream); // Save all redirects from xml file CustomRedirectCollection redirects = parser.Load(0); string message; if (redirects != null && redirects.Count != 0) { CustomRedirectHandler.Current.SaveCustomRedirects(redirects); message = string.Format(LocalizationService.Current.GetString("/gadget/redirects/importsuccess"), redirects.Count); } else { message = LocalizationService.Current.GetString("/gadget/redirects/importnone"); } return(new FileUploadJsonResult { Data = new { message } }); }