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); } } }
protected void SubmitClick(object sender, EventArgs e) { using (var eds = new Data.WikipediaEntities()) { Data.Article art = ViewState["article"] as Data.Article; if ((ArticleName.Text != art.Name || ArticleContent.Text != art.Content) && (!art.IsProtected || Request.IsAuthenticated)) { 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(); } Response.Redirect("~/Article.aspx?id=" + art.Id); } }