public ActionResult Edit(ArticleModel model, bool continueEditing)
        {
            var article = _articleService.GetArticleById(model.Id);

            if (ModelState.IsValid)
            {
                int prevPictureId = article.PictureId;

                article = model.ToEntity(article);
                article.UpdateDate = DateTime.Now;

                if (model.CategoryId == 0)
                    article.CategoryId = null;

                //标签
                var allTags = _articleService.GetAllTag().ToList();
                foreach (var tag in allTags)
                {
                    if (model.SelectedTags != null && model.SelectedTags.Contains(tag.Id))
                    {
                        if (article.Tags.Count(t => t.Id == tag.Id) == 0)
                        {
                            article.Tags.Add(tag);
                        }
                    }
                    else
                    {
                        if (article.Tags.Count(t => t.Id == tag.Id) > 0)
                        {
                            article.Tags.Remove(tag);
                        }
                    }
                }

                _articleService.UpdateArticle(article);

                //图片处理, 删除旧图片
                if (prevPictureId > 0 && prevPictureId != article.PictureId)
                {
                    var prevPicture = _pictureService.GetPictureById(prevPictureId);
                    if (prevPicture != null)
                        _pictureService.DeletePicture(prevPicture);
                }

                SuccessNotification("保存成功");
                return continueEditing ? RedirectToAction("Edit", new { id = article.Id }) : RedirectToAction("List");
            }

            PrepareModel(model, article);

            return View(model);
        }
        public ActionResult Create(ArticleModel model, bool continueEditing)
        {
            if (ModelState.IsValid)
            {
                var article = model.ToEntity();
                article.CreateDate = DateTime.Now;
                article.UpdateDate = DateTime.Now;

                if (model.CategoryId == 0)
                    article.CategoryId = null;

                //标签
                foreach (var id in model.SelectedTags)
                {
                    article.Tags.Add(_articleService.GetTagById(id));
                }

                _articleService.InsertArticle(article);

                SuccessNotification("添加成功");

                return continueEditing ? RedirectToAction("Edit", new { id = article.Id }) : RedirectToAction("List");
            }

            PrepareModel(model);

            return View(model);
        }