示例#1
0
        public ActionResult Edit(Article article, HttpPostedFileBase ArticleImage)
        {
            ModelState.Remove("CreatedOn");
            ModelState.Remove("ModifiedOn");
            ModelState.Remove("ModifierUser");

            if (ModelState.IsValid)
            {
                bool result = UploadManager.ArticleImageUpdate(article, ArticleImage);

                Article db_article = article_mngr.Find(x => x.Id == article.Id);
                db_article.IsDraft    = article.IsDraft;
                db_article.CategoryId = article.CategoryId;
                db_article.Text       = article.Text;
                db_article.Title      = article.Title;
                if (result)
                {
                    db_article.ArticleImageFileName = article.ArticleImageFileName;
                }

                article_mngr.Update(db_article);

                return(RedirectToAction("Index"));
            }
            ViewBag.CategoryId = new SelectList(CacheHelper.GetCategoriesFromCache(), "Id", "Title", article.CategoryId);
            return(View(article));
        }