// GET: NewsArticles/Create public ActionResult Create() { var newsEditorModel = new NewsEditorModel { Editor = new Editor(System.Web.HttpContext.Current, "NewsEditor"), SelectedArticle = new NewsArticle() }; newsEditorModel.Editor.LoadFormData(string.Empty); newsEditorModel.Editor.MvcInit(); return(View(newsEditorModel)); }
public ActionResult Create([Bind(Include = "NewsArticleId,Header,IsFeatured, NewsEditor")] NewsArticle newsArticle) { newsArticle.Content = newsArticle.NewsEditor; if (ModelState.IsValid) { db.NewsArticles.Add(newsArticle); db.SaveChanges(); return(RedirectToAction("Index")); } var newsEditorModel = new NewsEditorModel { Editor = new Editor(System.Web.HttpContext.Current, "NewsEditor"), SelectedArticle = newsArticle }; newsEditorModel.Editor.LoadFormData(newsArticle.Content); newsEditorModel.Editor.MvcInit(); return(View(newsEditorModel)); }
// GET: NewsArticles/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } NewsArticle newsArticle = db.NewsArticles.Find(id); if (newsArticle == null) { return(HttpNotFound()); } var newsEditorModel = new NewsEditorModel { Editor = new Editor(System.Web.HttpContext.Current, "NewsEditor"), SelectedArticle = newsArticle }; newsEditorModel.Editor.LoadFormData(newsArticle.Content); newsEditorModel.Editor.MvcInit(); return(View(newsEditorModel)); }