public HttpResponseMessage GetNewsFeed(HttpRequestMessage request, [FromUri] int page) { return(GetHttpResponse(request, () => { HttpResponseMessage response = null; string userId = User.Identity.GetUserId(); List <NewsFeedModel> newsFeedModel = new List <NewsFeedModel>(); List <Ad> ads = new List <Ad>(); List <AdApplication> adApplications = adApplicationRespository.FindUserAdApplications(userId, page); foreach (var adapplication in adApplications) { NewsFeedModel newsFeedItem = new NewsFeedModel(); Ad newsfeedad = adRepository.Get(adapplication.AdId); newsFeedItem.AdDetails = newsfeedad; newsFeedItem.AdApplication = adapplication; newsFeedModel.Add(newsFeedItem); } response = request.CreateResponse(HttpStatusCode.OK, newsFeedModel); return response; })); }
public string AddComment(NewsFeedModel comment) { string status = ""; string query; DataTable dt1 = new DataTable(); SQLiteCommand cmd; try { dbConn.Open(); query = "insert into news_feed values (" + comment.UserId + ", '" + comment.FirstName + "', '" + comment.LastName + "', '" + comment.Comment + "', "+ comment.Month + ", " + comment.Day + ", " + comment.Year + ", " + comment.Hour + ", " + comment.Minute + ")"; cmd = new SQLiteCommand(query, dbConn); cmd.ExecuteNonQuery(); status = "Comment Added"; dbConn.Close(); } catch (SQLiteException ex) { Console.Write(ex.ToString()); status = ex.ToString(); dbConn.Close(); } return status; }
public NewsFeedModel GetNews(string newsFeed, string storyCount) { _news = new NewsFeedModel(); var loadedEventArgs = new LoadEventArgs(); string queryString = string.Format("{0}?feed={1}&pageSize={2}", Settings.NewsUrl, newsFeed ?? "", storyCount ?? ""); var webClient = new SharpGIS.GZipWebClient(); Observable.FromEvent <DownloadStringCompletedEventArgs>(webClient, "DownloadStringCompleted") .ObserveOn(Scheduler.ThreadPool) .Select(x => ProcessNews(x.EventArgs.Result)) .ObserveOn(Scheduler.Dispatcher) .Subscribe(s => { BuildNewsFeedModel(s); loadedEventArgs.IsLoaded = true; loadedEventArgs.Message = ""; OnNewsLoaded(loadedEventArgs); }, e => { loadedEventArgs.IsLoaded = false; loadedEventArgs.Message = e.Message.ToString(CultureInfo.InvariantCulture); OnNewsLoaded(loadedEventArgs); }); webClient.DownloadStringAsync(new Uri(queryString)); return(_news); }
private void LoadThisMonthNewsFeeds() { var model = new NewsFeedModel(); model.Feeds = this.Model.Feeds; this.ThisMonthNewsFeedControl.DataContext = model; }
private void LoadThisWeekNewsFeeds() { var model = new NewsFeedModel(); var createdDate = new DateRangeCriteria("thisweek"); model.Feeds = this.Model.Feeds.Where(feed => feed.CreatedDate.Date >= createdDate.DateFrom && feed.CreatedDate.Date <= createdDate.DateTo); this.ThisWeekNewsFeedControl.DataContext = model; }
private async void getNewsFeed() { HttpClient client = new HttpClient(); string url = "http://192.168.0.102:8080/Project2CE1103_war_exploded/resource/USUARIOS/newsFeed/" + LoginPage.username; var resultado = await client.GetAsync(url); var json = resultado.Content.ReadAsStringAsync().Result; NewsFeedModel[] feed = NewsFeedModel.FromJson(json); NewsList.ItemsSource = feed; }
private void Load() { this.BusyIndicator.Visibility = Visibility.Visible; var model = new NewsFeedModel(); model.Token = this.Token; model.CreatedDate = "thismonth"; model.LoadCompleted += LoadCompleted; this.Model = model; model.Load(); }
public void LoadData(string feedName) { KeyValuePair <string, string> feedValue; bool feedKey = Settings.RssFeeds.TryGetValue(feedName.ToLower(), out feedValue); if (!feedKey) { NewsFeed = new NewsFeedModel(); } NewsPageTitle = !string.IsNullOrWhiteSpace(feedValue.Key) ? feedValue.Key : "Recent Items"; NewsFeed = Service.GetNews(feedName, "8"); NewsItems = NewsFeed.Items; }
public void ShowAlerts(bool show_alerts) { NewsFeedModel model = this.GetComponent <NewsFeedModel>(); if (model != null) { model.SetShowAlerts(show_alerts); } else { Debug.LogError("NewsFeedController::ShowAlerts -- GameObject does not have \"Model\" reference!"); } if (show_alerts) { // Position List accordingly // For now, i'm having the alerts just appear/disappear -- no "sliding" in fancy stuff yet } }
private void BuildNewsFeedModel(NewsFeedModel data) { _news.Title = data.Title; _news.Description = data.Description; _news.Copyright = data.Copyright; _news.Link = data.Link; _news.Language = data.Language; _news.ImageUrl = data.ImageUrl; foreach (NewsItemModel item in data.Items) { var newsItem = new NewsItemModel { Title = item.Title, ArticleLink = item.ArticleLink, Date = item.Date, Description = item.Description, ImageUrl = Coalesce(item.ImageUrl, Settings.DefaulImage).ToString() }; _news.Items.Add(newsItem); } }
public List<NewsFeedModel> GetNewsFeed() { string query; SQLiteCommand cmd; NewsFeedModel nfModel; List<NewsFeedModel> newsFeed = new List<NewsFeedModel>(); try { dbConn.Open(); query = "select * from news_feed"; DataTable dt = new DataTable(); using (cmd = new SQLiteCommand(query, dbConn)) { using (SQLiteDataReader dr = cmd.ExecuteReader()) { // Load the reader data into the DataTable dt.Load(dr); // While there are rows in the returned data create EventModels and add them to the EventModel list for (int i = 0; i < dt.Rows.Count; i++) { nfModel = new NewsFeedModel(dt.Rows[i]); newsFeed.Add(nfModel); } } } dbConn.Close(); } catch (SQLiteException ex) { Console.Write(ex.ToString()); dbConn.Close(); } return newsFeed.Take(20).ToList(); }
private void Awake() { if (instance == null) { instance = this; } else { Destroy(this.gameObject); } mView = this.gameObject.GetComponent <NewsFeedView>(); if (mView == null) { mView = this.gameObject.AddComponent <NewsFeedView>(); } mModel = this.gameObject.GetComponent <NewsFeedModel>(); if (mModel == null) { mModel = this.gameObject.AddComponent <NewsFeedModel>(); } }
public ActionResult NewsFeed() { NewsFeedModel model = new NewsFeedModel(); int artistId = WebSecurity.CurrentUserId; try { var obj = m_context.GetUserAlerts(artistId); if (obj != null) { model.NewsFeed = obj.ToList(); } if (model.NewsFeed.Count() == 0) { return(PartialView("_NoDataPartial", "Sorry, we could not find any stories that match your interests.")); } } catch { //TODO: Log exception return(PartialView("_NoDataPartial", "Sorry could not access the data.")); } return(PartialView("_NewsFeedPartial", model)); }
public void AddEvent() { CalendarData cd = new CalendarData(); string[] name = cd.AddEvent(this); if (name[0] != null) { // Add a comment in the news feed for this event string firstName = name[0].ToString(); string lastName = name[1].ToString(); string comment = firstName + " " + lastName + " added " + Type.ToString() + " " + Title + "!"; NewsFeedModel nm = new NewsFeedModel(CreatedById, name[0].ToString(), name[1].ToString(), comment); NewsFeedData nd = new NewsFeedData(); nd.AddComment(nm); } }