Beispiel #1
0
        public ActionResult Edit(ShipCompanyModel model, int shipCoId = -1)
        {
            ShipCompanyInfo shipCompanyInfo = AdminShipCompanies.GetShipCompanyById(shipCoId);

            if (shipCompanyInfo == null)
            {
                return(PromptView("配送公司不存在"));
            }

            int shipCoId2 = AdminShipCompanies.GetShipCoIdByName(model.CompanyName);

            if (shipCoId2 > 0 && shipCoId2 != shipCoId)
            {
                ModelState.AddModelError("CompanyName", "名称已经存在");
            }

            if (ModelState.IsValid)
            {
                shipCompanyInfo.DisplayOrder = model.DisplayOrder;
                shipCompanyInfo.Name         = model.CompanyName;

                AdminShipCompanies.UpdateShipCompany(shipCompanyInfo);
                AddAdminOperateLog("修改配送公司", "修改配送公司,配送公司ID为:" + shipCoId);
                return(PromptView("配送公司修改成功"));
            }

            ViewData["referer"] = ShopUtils.GetAdminRefererCookie();
            return(View(model));
        }
Beispiel #2
0
        public ActionResult Add(ShipCompanyModel model)
        {
            if (AdminShipCompanies.GetShipCoIdByName(model.CompanyName) > 0)
            {
                ModelState.AddModelError("CompanyName", "名称已经存在");
            }

            if (ModelState.IsValid)
            {
                ShipCompanyInfo shipCompanyInfo = new ShipCompanyInfo()
                {
                    Name         = model.CompanyName,
                    DisplayOrder = model.DisplayOrder
                };

                AdminShipCompanies.CreateShipCompany(shipCompanyInfo);
                AddAdminOperateLog("添加配送公司", "添加配送公司,配送公司为:" + model.CompanyName);
                return(PromptView("配送公司添加成功"));
            }
            ViewData["referer"] = ShopUtils.GetAdminRefererCookie();
            return(View(model));
        }