コード例 #1
0
        /**** Published Articles ****/

        public void PublishArticle(Articles article)
        {
            PublishedArticles articleToPublish = new PublishedArticles()
            {
                articleId     = article.articleId,
                articleTypeId = article.articleTypeId,
                body          = article.body,
                headline      = article.headline,
                strapline     = article.strapline,
                userid        = article.userid,
                datePublished = article.datePublished,
                isPublished   = true
            };
            var originalPublishedArticle = (from pa in _dataModel.PublishedArticles where pa.articleId == article.articleId select pa);

            if (originalPublishedArticle.Count() > 0)
            {
                _dataModel.ApplyCurrentValues(originalPublishedArticle.First().EntityKey.EntitySetName, articleToPublish);
            }
            else
            {
                _dataModel.AddToPublishedArticles(articleToPublish);
            }
            _dataModel.SaveChanges();
        }
コード例 #2
0
 private PublishedArticles ExtendPublishedArticle(PublishedArticles article)
 {
     article.user        = (from u in _userService.GetList() where u.userId == article.userid select u).First();
     article.articleType = (from at in new ArticleTypeService().GetArticleTypesList() where at.articleTypeId == article.articleTypeId select at).First();
     article.Description = Utils.GetSummary(Utils.StripHtml(article.body), 255);
     article.Url         = string.Format("{0}/{1}", Utils.StripInvalid(article.headline), article.articleId);
     return(article);
 }
コード例 #3
0
        public void AddFacebookComment(FacebookUser fbUser, string comment, PublishedArticles article)
        {
            var fbPost = new FacebookPost();
            fbPost.articleId = article.articleId;
            fbPost.facebookId = fbUser.facebookId;
            fbPost.post = comment;

            _dataModel.AddToFacebookPosts(fbPost);
        }
コード例 #4
0
 public void AddFacebookCommentTest()
 {
     FacebookService target = new FacebookService();
     FBUser fbUser = new FBUser(12345, "a token", "theUsername", "f");
     string comment = "this is a facebook comment";
     PublishedArticles article = new PublishedArticles();
     article.articleId = 1;
     target.AddFacebookComment(fbUser, comment, article);
 }
コード例 #5
0
        public void AddFacebookComment(FacebookUser fbUser, string comment, PublishedArticles article)
        {
            var fbPost = new FacebookPost();

            fbPost.articleId  = article.articleId;
            fbPost.facebookId = fbUser.facebookId;
            fbPost.post       = comment;

            _dataModel.AddToFacebookPosts(fbPost);
        }
コード例 #6
0
        public PublishedArticles GetArticleByArticleType(int articleTypeId)
        {
            PublishedArticles article = null;
            var articles = (from a in _dataModel.PublishedArticles where a.articleTypeId == articleTypeId orderby a.datePublished descending select a);

            if (articles.Count() > 0)
            {
                article = articles.First();
                ExtendPublishedArticle(article);
            }
            return(article);
        }
コード例 #7
0
        /**** Published Articles ****/
        public void PublishArticle(Articles article)
        {
            PublishedArticles articleToPublish = new PublishedArticles()
            {
                articleId = article.articleId,
                articleTypeId = article.articleTypeId,
                body = article.body,
                headline = article.headline,
                strapline = article.strapline,
                userid = article.userid,
                datePublished = article.datePublished,
                isPublished = true
            };
            var originalPublishedArticle = (from pa in _dataModel.PublishedArticles where pa.articleId == article.articleId select pa);
            if (originalPublishedArticle.Count() > 0)
            {
                _dataModel.ApplyCurrentValues(originalPublishedArticle.First().EntityKey.EntitySetName, articleToPublish);
            }
            else
            {
                _dataModel.AddToPublishedArticles(articleToPublish);

            }
            _dataModel.SaveChanges();
        }
コード例 #8
0
 private PublishedArticles ExtendPublishedArticle(PublishedArticles article)
 {
     article.user = (from u in _userService.GetList() where u.userId == article.userid select u).First();
     article.articleType = (from at in new ArticleTypeService().GetArticleTypesList() where at.articleTypeId == article.articleTypeId select at).First();
     article.Description = Utils.GetSummary(Utils.StripHtml(article.body), 255);
     article.Url = string.Format("{0}/{1}", Utils.StripInvalid(article.headline), article.articleId);
     return article;
 }
コード例 #9
0
 /// <summary>
 /// Deprecated Method for adding a new object to the PublishedArticles EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPublishedArticles(PublishedArticles publishedArticles)
 {
     base.AddObject("PublishedArticles", publishedArticles);
 }
コード例 #10
0
 /// <summary>
 /// Create a new PublishedArticles object.
 /// </summary>
 /// <param name="articleId">Initial value of the articleId property.</param>
 /// <param name="dateCreated">Initial value of the dateCreated property.</param>
 /// <param name="isPublished">Initial value of the isPublished property.</param>
 public static PublishedArticles CreatePublishedArticles(global::System.Int32 articleId, global::System.DateTime dateCreated, global::System.Boolean isPublished)
 {
     PublishedArticles publishedArticles = new PublishedArticles();
     publishedArticles.articleId = articleId;
     publishedArticles.dateCreated = dateCreated;
     publishedArticles.isPublished = isPublished;
     return publishedArticles;
 }