Esempio n. 1
0
 public Task<vpostinfo> Task_info_query(a_articles article)
 {
     return Task<vpostinfo>.Run(() => {
         return (from pi in db.vpostinfoes
                 where pi.pi_postID == article.a_p_id
                 select pi).Distinct().ToList().First();
     });
 }
Esempio n. 2
0
 private async void builderArticleInfo (a_articles article) {
     if(article == null) {
         articleid.Text = "-"; articledate.Text = "-"; articleauthor.Text = "-"; articletitle.Text = "-"; articlecontent.Text = "-";
     } else {
         list.IsEnabled = false;
         articles.IsEnabled = false;
         var info = await controller.Task_info_query(article);
         list.IsEnabled = true;
         articles.IsEnabled = true;
         articleid.Text = info.pi_postID.ToString();
         articledate.Text = info.pi_postDate.ToString();
         articleauthor.Text = info.pi_user;
         articletitle.Text = info.pi_postTitle.Length > 20 ? info.pi_postTitle.Substring(0, 20) + " ..." : info.pi_postTitle;
         articlecontent.Text = info.pi_postContent.Length > 20 ? info.pi_postContent.Substring(0, 20)+" ..." : info.pi_postContent;
     }
 }
Esempio n. 3
0
        private async void submitArticle_Click(object sender, RoutedEventArgs e)
        {
            string author = newArticleAuthor.Text;
            string title = newArticleTitle.Text;
            string content = newArticleContent.Text;

            p_posts post = new p_posts();
            post.p_id = ((from p in db.p_posts
                          select p.p_id).Max()) + 1;
            post.p_content = content;
            post.p_date = DateTime.Now;
            post.p_u_username = author;

            a_articles article = new a_articles();
            article.a_p_id = post.p_id;
            article.a_title = title;
            article.a_c_clove = ((vcloveinfo)list.SelectedItem).ci_cloveID;
            article.a_r_rank = null;

            db.p_posts.Add(post);
            db.a_articles.Add(article);

            db.SaveChanges();

            articles.ItemsSource = await controller.Task_articles_ItemsSource((vcloveinfo)list.SelectedItem);
            articles.DisplayMemberPath = "a_title";

            newArticleAuthor.Text = "";
            newArticleTitle.Text = "";
            newArticleContent.Text = "";
        }