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); AddMallAdminLog("添加配送公司", "添加配送公司,配送公司为:" + model.CompanyName); return PromptView("配送公司添加成功"); } ViewData["referer"] = MallUtils.GetMallAdminRefererCookie(); return View(model); }
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); AddMallAdminLog("修改配送公司", "修改配送公司,配送公司ID为:" + shipCoId); return PromptView("配送公司修改成功"); } ViewData["referer"] = MallUtils.GetMallAdminRefererCookie(); return View(model); }
public ActionResult Add() { ShipCompanyModel model = new ShipCompanyModel(); ViewData["referer"] = MallUtils.GetMallAdminRefererCookie(); return View(model); }
public ActionResult Edit(int shipCoId = -1) { ShipCompanyInfo shipCompanyInfo = AdminShipCompanies.GetShipCompanyById(shipCoId); if (shipCompanyInfo == null) return PromptView("配送公司不存在"); ShipCompanyModel model = new ShipCompanyModel(); model.DisplayOrder = shipCompanyInfo.DisplayOrder; model.CompanyName = shipCompanyInfo.Name; ViewData["referer"] = MallUtils.GetMallAdminRefererCookie(); return View(model); }