Esempio n. 1
0
        public async Task <ActionResult> Create([Bind(Include = "SourceId,Url,Description")] Source source)
        {
            if (!string.IsNullOrEmpty(source.Url))
            {
                try
                {
                    WebClient wclient  = new WebClient();
                    string    newsData = wclient.DownloadString(source.Url);

                    XDocument xml = XDocument.Parse(newsData);
                    if (ModelState.IsValid)
                    {
                        db.Sources.Add(source);
                        await db.SaveChangesAsync();

                        return(RedirectToAction("Index"));
                    }
                }
                catch
                {
                }
            }


            return(View(source));
        }