예제 #1
0
        public async Task <IActionResult> Post(RssSourceModel rssSourceModel)
        {
            try
            {
                await _rssSourceService.CreateOneRssSource(rssSourceModel);

                return(Ok($"SrrSource \"{rssSourceModel.Name}\" was successfully created"));
            }
            catch (Exception ex)
            {
                BadRequest(ex.Message);
                throw;
            }
        }
예제 #2
0
 public async Task <IActionResult> Create(RssSourceModel rssSourceModel)
 {
     if (ModelState.IsValid)
     {
         try
         {
             using (var reader = XmlReader.Create(rssSourceModel.Url))
             {
                 var feed = SyndicationFeed.Load(reader);
                 reader.Close();
             }
             await _rssSourceService.CreateOneRssSource(rssSourceModel);
         }
         catch (Exception ex)
         {
             Log.Error($"Something went wrong when trying to add to the source. Message: {ex.Message}");
             return(BadRequest($"Something went wrong when trying to add to the source. Incorrect Rss Sourse adress!"));
         }
     }
     return(RedirectToAction(nameof(Index)));
 }