public int AddSuggestedNews(SuggestedNews news) { suggestedNewsRepository.Add(news); suggestedNewsRepository.SaveChanges(); return(news.Id); }
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)); } }
private void SuggestionNotify(SuggestedNews news) { telegramService.SendAsync(Settings.TelegramSuggestionChannelId, news.LinkToArticle); }