Exemplo n.º 1
0
        public ActionResult Edit(Novel novel)
        {
            string result = "更新失败";

            if (Session["UserId"] == null)
            {
                return Content("长时间未操作,请重新登录。");
            }

            if (novel == null)
            {
                result = "参数为空";
            }
            else
            {
                if (!string.IsNullOrEmpty(novel.Title) &&
                    !string.IsNullOrEmpty(novel.CategoryId) &&
                    !string.IsNullOrEmpty(novel.Name))
                {
                    NovelService novelService = new NovelService();

                    Novel oldNovel = novelService.GetNovelById(novel.Id);
                    if (oldNovel != null)
                    {
                        oldNovel.CategoryId = string.IsNullOrEmpty(novel.CategoryId) ? string.Empty : novel.CategoryId;
                        oldNovel.Title = string.IsNullOrEmpty(novel.Title) ? string.Empty : novel.Title;
                        oldNovel.Keywords = string.IsNullOrEmpty(novel.Keywords) ? string.Empty : novel.Keywords;
                        oldNovel.Description = string.IsNullOrEmpty(novel.Description) ? string.Empty : novel.Description;
                        oldNovel.Name = string.IsNullOrEmpty(novel.Name) ? string.Empty : novel.Name;
                        oldNovel.Author = string.IsNullOrEmpty(novel.Author) ? string.Empty : novel.Author;
                        result = novelService.EditNovel(novel);
                    }
                }
                else
                {
                    result = "必填项 [标题、分类、名称、作者] 不能为空";
                }
            }

            return Content(result);
        }
Exemplo n.º 2
0
        public ActionResult Edit(int id)
        {
            if (Session["UserId"] == null)
            {
                return Redirect("/admin/login");
            }

            NovelModel model = new NovelModel();

            NovelService novelService = new NovelService();
            model.NovelCategories = novelService.GetNovelCategories();
            model.Novel = novelService.GetNovelById(id);

            return View(model);
        }