public async Task <IActionResult> EditGoods(GoodsEditViewModel webModel) { if (ModelState.IsValid) { bool flag; if (string.IsNullOrEmpty(webModel.Id)) { //Add Data flag = await _service.InsertGoodsAsync(webModel, _context); } else { //Update Data flag = await _service.UpdateGoodsAsync(webModel, _context); } return(Json(new { success = flag, msg = flag ? "物品信息编辑成功" : "物品信息编辑失败" })); } return(Json(new { success = false, msg = this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors).FirstOrDefault().ErrorMessage })); }