Esempio n. 1
0
 public ArticleOpResult AddTextArticle(Article article, Vote vote)
 {
     vote.ArticleID = article.ArticleID = Guid.NewGuid().ToString();
     vote.VoteID = article.ContentID = Guid.NewGuid().ToString();
     article.ContentType = (int)PostContentType.TextContents;
     article.Votes.Clear();
     article.Votes.Add(vote);
     article.AddTime = DateTime.Now;
     article.UpdateTime = DateTime.Now;
     this.Articles.Add(article);
     return new ArticleOpResult() { HasError = false, ArticleID = article.ArticleID };
 }
Esempio n. 2
0
 public ArticleOpResult AddTextArticle(Article textArticle,TextContent content)
 {
     content.ArticleID = textArticle.ArticleID = Guid.NewGuid().ToString();
     content.ContentID = textArticle.ContentID = Guid.NewGuid().ToString();
     textArticle.ContentType = (int)PostContentType.TextContents;
     textArticle.TextContents.Clear();
     textArticle.TextContents.Add(content);
     textArticle.AddTime = DateTime.Now;
     textArticle.UpdateTime = DateTime.Now;
     this.Articles.Add(textArticle);
     //this.DBContext.TextContents.Add(content);
     try
     {
         this.DBContext.SaveChanges();
     }
     catch (DbEntityValidationException ex)
     {
     }
     return new ArticleOpResult() { HasError = false , ArticleID=textArticle.ArticleID};
 }
Esempio n. 3
0
 private PostModelBase GetPostModelFromArticle(Article article, TextContent textContent, Vote vote, List<VotesItemModel> voteItems)
 {
     switch ((PostContentType)article.ContentType)
     {
         case PostContentType.TextContents:
             return new ContentPostModel()
             {
                 AddDateTime = article.AddTime,
                 SubjectID = article.SubjectID,
                 SubjectName = article.Subject.Name,
                 TopicName = article.Tittle,
                 PostContentType = PostContentType.TextContents,
                 TopicContent = textContent.Content
             };
         case PostContentType.Votes:
             var item= new VotePostModle()
             {
                 AddDateTime = article.AddTime,
                 SubjectID = article.SubjectID,
                 SubjectName = article.Subject.Name,
                 TopicName = article.Tittle,
                 PostContentType = PostContentType.TextContents,
                 IsMutipleVote = vote.IsMultiple > 1,
             };
             var list = from it in voteItems select new VotesItemModel() { };
             item.VoteItems = list.ToList();
             return item;
         default:
             return null;
     }
 }
Esempio n. 4
0
 private Vote VoteContent2VoteContent(VotePostModle post, Article article)
 {
     var vote= new Vote()
     {
          ArticleID=article.ArticleID,
     };
     post.VoteItems.ForEach(item=>
     {
         vote.VoteItems.Add(new VoteItem()
         {
         });
     });
     return vote;
 }
Esempio n. 5
0
 private TextContent ContentModel2TextContent(ContentPostModel post,Article article)
 {
     return new TextContent()
     {
         Content=post.TopicContent,
          ArticleID=article.ArticleID
     };
 }