コード例 #1
0
        public ActionResult Edit(ArticleModel model, int id)
        {
            if (ModelState.IsValid)
            {
                var article = jlService.GetArticle(id);
                article.AddTime = model.AddTime ?? article.AddTime;
                article.Title   = model.Title;
                article.Brief   = model.Brief;
                article.Content = model.Content;
                article.Status  = model.IsPublished ? 0 : 1;

                // picture
                if (Request.Files != null &&
                    Request.Files.Count > 0 &&
                    Request.Files[0].ContentLength > 0)
                {
                    var imgLink = FileHelper.SaveArticleImage(Request.Files[0]);
                    article.Picture = imgLink;
                }

                jlService.UpdateArticle(article);
                ViewData.Add("ResultObject", ResultObject.Succeed());

                // for show
                model.Picture = article.Picture;
            }
            return(View(model));
        }