Пример #1
0
        public ActionResult AddNewsType(NewsTypeModel model)
        {
            if (AdminNews.GetNewsTypeByName(model.NewsTypeName) != null)
                ModelState.AddModelError("NewsTypeName", "名称已经存在");

            if (ModelState.IsValid)
            {
                NewsTypeInfo newsTypeInfo = new NewsTypeInfo()
                {
                    Name = model.NewsTypeName,
                    DisplayOrder = model.DisplayOrder
                };

                AdminNews.CreateNewsType(newsTypeInfo);
                AddAdminOperateLog("添加新闻类型", "添加新闻类型,新闻类型为:" + model.NewsTypeName);
                return PromptView("新闻类型添加成功");
            }
            ViewData["referer"] = ShopUtils.GetAdminRefererCookie();
            return View(model);
        }
Пример #2
0
        public ActionResult EditNewsType(NewsTypeModel model, int newsTypeId = -1)
        {
            NewsTypeInfo newsTypeInfo = AdminNews.GetNewsTypeById(newsTypeId);
            if (newsTypeInfo == null)
                return PromptView("新闻类型不存在");

            NewsTypeInfo newsTypeInfo2 = AdminNews.GetNewsTypeByName(model.NewsTypeName);
            if (newsTypeInfo2 != null && newsTypeInfo2.NewsTypeId != newsTypeId)
                ModelState.AddModelError("NewsTypeName", "名称已经存在");

            if (ModelState.IsValid)
            {
                newsTypeInfo.Name = model.NewsTypeName;
                newsTypeInfo.DisplayOrder = model.DisplayOrder;

                AdminNews.UpdateNewsType(newsTypeInfo);
                AddAdminOperateLog("修改新闻类型", "修改新闻类型,新闻类型ID为:" + newsTypeId);
                return PromptView("新闻类型修改成功");
            }

            ViewData["referer"] = ShopUtils.GetAdminRefererCookie();
            return View(model);
        }
Пример #3
0
 public ActionResult AddNewsType()
 {
     NewsTypeModel model = new NewsTypeModel();
     ViewData["referer"] = ShopUtils.GetAdminRefererCookie();
     return View(model);
 }
Пример #4
0
        public ActionResult EditNewsType(int newsTypeId = -1)
        {
            NewsTypeInfo newsTypeInfo = AdminNews.GetNewsTypeById(newsTypeId);
            if (newsTypeInfo == null)
                return PromptView("新闻类型不存在");

            NewsTypeModel model = new NewsTypeModel();
            model.NewsTypeName = newsTypeInfo.Name;
            model.DisplayOrder = newsTypeInfo.DisplayOrder;
            ViewData["referer"] = ShopUtils.GetAdminRefererCookie();

            return View(model);
        }