Пример #1
0
        public int AddSuggestedNews(SuggestedNews news)
        {
            suggestedNewsRepository.Add(news);
            suggestedNewsRepository.SaveChanges();

            return(news.Id);
        }
Пример #2
0
        public ActionResult SuggestNews(SuggestedNews news)
        {
            if (news.LinkToArticle == null)
            {
                return(new HttpStatusCodeResult(422, Strings.ParameterMissed));
            }

            try
            {
                news.Ip    = GetIpAddress();
                news.Title = suggestedNewsService.TryGetTitleFromUrl(news.LinkToArticle);
                suggestedNewsService.AddSuggestedNews(news);
                SuggestionNotify(news);

                return(new HttpStatusCodeResult(200));
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(500, ex.Message));
            }
        }
Пример #3
0
 private void SuggestionNotify(SuggestedNews news)
 {
     telegramService.SendAsync(Settings.TelegramSuggestionChannelId, news.LinkToArticle);
 }