private void Init() { //Create twitter news var tweet1 = new TwitterNews(context); tweet1.Identifier = "1"; tweet1.Title = "Twitter ESA"; tweet1.Author = "ESA"; tweet1.Store(); var tweet2 = new TwitterNews(context); tweet2.Identifier = "2"; tweet2.Title = "Twitter Terradue"; tweet2.Author = "terradue"; tweet2.Store(); //create rss news var rss1 = new RssNews(context); rss1.Identifier = "3"; rss1.Title = "RSS worldbank"; rss1.Url = "http://blogs.worldbank.org/water/rss.xml"; rss1.Store(); }
public object Post(CreateNews request) { WebNews result = null; var context = TepWebContext.GetWebContext(PagePrivileges.AdminOnly); try { context.Open(); if (request.Type.Equals(EntityType.GetEntityType(typeof(TwitterNews)).Keyword)) { TwitterNews tweet = null; tweet = new TwitterNews(context); tweet = (TwitterNews)request.ToEntity(context, tweet); tweet.Store(); result = new WebNews(tweet); } else if (request.Type.Equals(EntityType.GetEntityType(typeof(RssNews)).Keyword)) { RssNews rss = null; rss = new RssNews(context); rss = (RssNews)request.ToEntity(context, rss); rss.Store(); result = new WebNews(rss); //} else if (request.Type.Equals(EntityType.GetEntityType(typeof(TumblrNews)).Keyword)){ // TumblrNews tumblr = null; // tumblr = new TumblrNews(context); // tumblr = (TumblrNews)request.ToEntity(context, tumblr); // tumblr.Store(); // result = new WebNews(tumblr); } else { Article article = null; article = new Article(context); article = (Article)request.ToEntity(context, article); article.Store(); result = new WebNews(article); } context.LogInfo(this, string.Format("/news POST Id='{0}'", request.Id)); context.Close(); } catch (Exception e) { context.LogError(this, e.Message, e); context.Close(); throw e; } return(result); }
public object Post(CreateTwitterNews request) { var context = TepWebContext.GetWebContext(PagePrivileges.EverybodyView); WebNews result = null; try{ context.Open(); context.LogInfo(this, string.Format("/news/twitter POST Id='{0}'", request.Id)); TwitterNews article = new TwitterNews(context); article = (TwitterNews)request.ToEntity(context, article); article.Store(); result = new WebNews(article); context.Close(); }catch (Exception e) { context.LogError(this, e.Message, e); context.Close(); throw e; } return(result); }