public IActionResult Update(string granariesId) { var dal = new GranariesDal(); var p = dal.Find(granariesId); var model = mapper.Map <GranariesUpdateModel>(p); return(View(model)); }
public IActionResult Delete(string granariesId) { var dal = new GranariesDal(); var p = dal.Find(granariesId); if (p == null) { return(Json(new { state = "error", data = "找不到这一条数据" })); } try { dal.Remove(p); return(Json(new { state = "ok", data = 1 })); } catch (Exception ex) { return(Json(new { state = "error", data = ex.Message })); } }
public IActionResult Update(GranariesUpdateModel model) { if (!ModelState.IsValid) { return(Json(new { state = "error", data = "提交信息验证失败" })); } try { var dal = new GranariesDal(); var p = dal.Find(model.GranariesId); mapper.Map(model, p); dal.Update(p); return(Json(new { state = "ok", data = 1 })); } catch (Exception ex) { return(Json(new { state = "error", data = ex.Message })); } }