public ActionResult ArticlePost(ArticleSubmitView articlePost) { var article = new Article { AuthorId = articlePost.AuthorId, Title = HttpUtility.HtmlEncode(articlePost.Title), SubTitle = articlePost.SubTitle, Content = articlePost.Content }; var tags = Request.Form["tags"]; if (article.Content != null) { article.Content = articlePost.Content.Replace("style=\"height:", "name=\"height:"); article.Content = HttpUtility.HtmlEncode(article.Content); } article.PostDate = DateTime.Now; var one = new ArticleStruct { Article = article, RootComments = new List<CommentLevel>() }; if (ModelState.IsValid && !string.IsNullOrEmpty(article.Title)) { var tagsId = GetTagId(tags); article.TagId1 = tagsId[0]; article.TagId2 = tagsId[1]; article.TagId3 = tagsId[2]; article.TagId4 = tagsId[3]; article.TagId5 = tagsId[4]; _db.Articles.Add(article); _db.SaveChanges(); return RedirectToAction("Index",new { articleId =article.ArticleId}); } return RedirectToAction("Index", "Home"); }
public ActionResult ArticlePreview(ArticleSubmitView articlePreview) { var article = new Article { AuthorId = articlePreview.AuthorId, Title = HttpUtility.HtmlEncode(articlePreview.Title), SubTitle = articlePreview.SubTitle, Content = articlePreview.Content }; ViewBag.AuthorName = (from a in _db.Members where a.UserId == articlePreview.AuthorId select string.IsNullOrEmpty(a.NickName) ? a.UserName : a.NickName).FirstOrDefault(); if (article.Content != null) { article.Content = articlePreview.Content.Replace("style=\"height:", "name=\"height:"); article.Content = HttpUtility.HtmlEncode(article.Content); } article.PostDate = DateTime.Now; var one = new ArticleStruct { Article = article, RootComments = new List<CommentLevel>() }; ViewBag.isPreView = true; return View("Index", one); }