public ActionResult InventoryLocation(InventoryLocationViewModel model) { if (ModelState.IsValid) { //名称编号不重复 var db = new DbEntities <InventoryLocation>().SimpleClient; if (db.IsAny(il => il.InventoryLocationName == model.InventoryLocationName || il.InventoryLocationNo == model.InventoryLocationNo)) { ModelState.AddModelError("InventoryLocationNo", "库位名称或编号已存在"); } else { //检验登录人身份,并获取对应ID if (new IdentityAuth().GetCurUserID(HttpContext, out int curUserID)) { InventoryLocation entity = model.InitAddInventoryLocation(curUserID); if (db.Insert(entity)) { TempData["Msg"] = $"库区 {entity.InventoryLocationName} 添加成功"; return(RedirectToAction("InventoryLocation", "Warehouse")); } TempData["Msg"] = "添加失败"; } else { TempData["Msg"] = "登录身份过期,请重新登录"; } } } SetSelectListItems.InventoryArea(this); return(View(model)); }
public ActionResult InventoryLocation() { SetSelectListItems.InventoryArea(this); return(View()); }