Esempio n. 1
0
        protected void SubmitClick(object sender, EventArgs e)
        {
            using (var eds = new Data.WikipediaEntities())
            {
                string stringid = Request.QueryString["id"];
                int id;

                if (int.TryParse(stringid, out id))
                {
                    /* create article */
                    Data.Article art = new Data.Article();
                    art.DomainId = id;
                    art.CreateDate = DateTime.Now;
                    if (Request.IsAuthenticated)
                        art.UserName = User.Identity.Name;
                    eds.Articles.AddObject(art);
                    eds.SaveChanges();

                    /* create article version */
                    Data.Version ver = new Data.Version();
                    ver.ArticleId = art.Id;
                    ver.Name = ArticleName.Text;
                    ver.Content = ArticleContent.Text;
                    ver.CreateDate = DateTime.Now;

                    eds.Versions.AddObject(ver);
                    eds.SaveChanges();

                    /* redirect to new article */
                    Response.Redirect("~/Article.aspx?id=" + art.Id);
                }
            }
        }
 /// <summary>
 /// Create a new Article object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="domainId">Initial value of the DomainId property.</param>
 /// <param name="isProtected">Initial value of the IsProtected property.</param>
 /// <param name="createDate">Initial value of the CreateDate property.</param>
 public static Article CreateArticle(global::System.Int32 id, global::System.Int32 domainId, global::System.Boolean isProtected, global::System.DateTime createDate)
 {
     Article article = new Article();
     article.Id = id;
     article.DomainId = domainId;
     article.IsProtected = isProtected;
     article.CreateDate = createDate;
     return article;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Articles EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToArticles(Article article)
 {
     base.AddObject("Articles", article);
 }