Exemplo n.º 1
0
        public ActionResult Edit(int id = -1)
        {
            NavInfo navInfo = AdminNavs.GetNavById(id);
            if (navInfo == null)
                return PromptView("导航不存在");

            NavModel model = new NavModel();
            model.Pid = navInfo.Pid;
            model.NavName = navInfo.Name;
            model.NavTitle = navInfo.Title;
            model.NavUrl = navInfo.Url;
            model.Target = navInfo.Target;
            model.DisplayOrder = navInfo.DisplayOrder;
            Load();

            return View(model);
        }
Exemplo n.º 2
0
        public ActionResult Add(NavModel model)
        {
            if (model.Pid != 0 && AdminNavs.GetNavById(model.Pid) == null)
                ModelState.AddModelError("Pid", "父导航不存在");

            if (ModelState.IsValid)
            {
                NavInfo navInfo = new NavInfo()
                {
                    Pid = model.Pid,
                    Name = model.NavName,
                    Title = model.NavTitle == null ? "" : model.NavTitle,
                    Url = model.NavUrl,
                    Target = model.Target,
                    DisplayOrder = model.DisplayOrder
                };

                AdminNavs.CreateNav(navInfo);
                AddMallAdminLog("添加导航", "添加导航,导航为:" + model.NavName);
                return PromptView("导航添加成功");
            }
            Load();
            return View(model);
        }
Exemplo n.º 3
0
        public ActionResult Edit(NavModel model, int id = -1)
        {
            NavInfo navInfo = AdminNavs.GetNavById(id);
            if (navInfo == null)
                return PromptView("导航不存在");

            if (model.Pid == navInfo.Id)
                ModelState.AddModelError("Pid", "不能将自己作为父导航");

            if (model.Pid != 0 && AdminNavs.GetNavById(model.Pid) == null)
                ModelState.AddModelError("Pid", "父导航不存在");

            if (model.Pid != 0 && AdminNavs.GetSubNavList(navInfo.Id).Exists(x => x.Id == model.Pid))
                ModelState.AddModelError("Pid", "不能将导航调整到自己子导航下");

            if (ModelState.IsValid)
            {
                int oldPid = navInfo.Pid;

                navInfo.Pid = model.Pid;
                navInfo.Name = model.NavName;
                navInfo.Title = model.NavTitle == null ? "" : model.NavTitle;
                navInfo.Url = model.NavUrl;
                navInfo.Target = model.Target;
                navInfo.DisplayOrder = model.DisplayOrder;

                AdminNavs.UpdateNav(navInfo, oldPid);
                AddMallAdminLog("修改导航", "修改导航,导航ID为:" + id);
                return PromptView("导航修改成功");
            }

            Load();
            return View(model);
        }
Exemplo n.º 4
0
 public ActionResult Add()
 {
     NavModel model = new NavModel();
     Load();
     return View(model);
 }