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 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 } }); }