Example #1
0
        public ActionResult NewUrl(NewUrlViewModel newUrlViewModel)
        {
            if (!_syndicationFeed.TryParseFeed(newUrlViewModel.Url))
            {
                ModelState.AddModelError("UrlInvalid", "The entered URL is invalid to load Feed");
                return(View(newUrlViewModel));
            }

            if (ModelState.IsValid && _service.AddNewUrl(newUrlViewModel.Url))
            {
                _service.Save();
                _cache.Clear();
                return(RedirectToAction("Index", "Sites"));
            }
            return(View(newUrlViewModel));
        }
Example #2
0
        public void ImportOpml(HttpPostedFileBase fileBase)
        {
            foreach (var outline in Opml.ParseOpml(fileBase.InputStream))
            {
                try
                {
                    if (!_syndicationFeed.TryParseFeed(outline.XMLUrl))
                    {
                        continue;
                    }

                    _siteService.AddNewUrl(outline.XMLUrl);
                    _siteService.Save();
                }
                catch (Exception)
                {
                }
            }

            _cache.Clear();
        }