示例#1
0
        public ActionResult Edit(int brandId = -1)
        {
            BrandInfo brandInfo = AdminBrands.GetBrandById(brandId);
            if (brandInfo == null)
                return PromptView("品牌不存在");

            BrandModel model = new BrandModel();
            model.DisplayOrder = brandInfo.DisplayOrder;
            model.BrandName = brandInfo.Name;
            model.Logo = brandInfo.Logo;
            Load();

            return View(model);
        }
示例#2
0
        public ActionResult Add(BrandModel model)
        {
            if (AdminBrands.GetBrandIdByName(model.BrandName) > 0)
                ModelState.AddModelError("BrandName", "名称已经存在");

            if (ModelState.IsValid)
            {
                BrandInfo brandInfo = new BrandInfo()
                {
                    DisplayOrder = model.DisplayOrder,
                    Name = model.BrandName,
                    Logo = model.Logo
                };

                AdminBrands.CreateBrand(brandInfo);
                AddAdminOperateLog("添加品牌", "添加品牌,品牌为:" + model.BrandName);
                return PromptView("品牌添加成功");
            }
            Load();
            return View(model);
        }
示例#3
0
        public ActionResult Edit(BrandModel model, int brandId = -1)
        {
            BrandInfo brandInfo = AdminBrands.GetBrandById(brandId);
            if (brandInfo == null)
                return PromptView("品牌不存在");

            int brandId2 = AdminBrands.GetBrandIdByName(model.BrandName);
            if (brandId2 > 0 && brandId2 != brandId)
                ModelState.AddModelError("BrandName", "名称已经存在");

            if (ModelState.IsValid)
            {
                brandInfo.DisplayOrder = model.DisplayOrder;
                brandInfo.Name = model.BrandName;
                brandInfo.Logo = model.Logo;

                AdminBrands.UpdateBrand(brandInfo);
                AddAdminOperateLog("修改品牌", "修改品牌,品牌ID为:" + brandId);
                return PromptView("品牌修改成功");
            }

            Load();
            return View(model);
        }
示例#4
0
 public ActionResult Add()
 {
     BrandModel model = new BrandModel();
     Load();
     return View(model);
 }