コード例 #1
0
 public ActionResult Edit( Article article )
 {
     if( ModelState.IsValid )
     {
         article.Body = Sanitizer.GetSafeHtml( article.Body );
         db.Articles.Attach( article );
         db.ObjectStateManager.ChangeObjectState( article, EntityState.Modified );
         db.SaveChanges();
         return RedirectToAction( "Index" );
     }
     return View( article );
 }
コード例 #2
0
        public ActionResult Create( Article article )
        {
            if( ModelState.IsValid )
            {
                article.Body = Sanitizer.GetSafeHtml( article.Body );
                db.Articles.AddObject( article );
                db.SaveChanges();
                return RedirectToAction( "Index" );
            }

            return View( article );
        }
 /// <summary>
 /// Create a new Article object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="title">Initial value of the Title property.</param>
 /// <param name="body">Initial value of the Body property.</param>
 /// <param name="publishDate">Initial value of the PublishDate property.</param>
 /// <param name="linkText">Initial value of the LinkText property.</param>
 public static Article CreateArticle(global::System.Int32 id, global::System.String title, global::System.String body, global::System.DateTime publishDate, global::System.String linkText)
 {
     Article article = new Article();
     article.Id = id;
     article.Title = title;
     article.Body = body;
     article.PublishDate = publishDate;
     article.LinkText = linkText;
     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);
 }