public IActionResult Add(string formulaId, int grainTypeId) { var grainDal = new GrainDal(); var model = new FormulaOfGrainAddModel() { FormulaId = formulaId, GrainTypeId = grainTypeId, Grains = grainDal.QueryByGrainTypeId(grainTypeId), }; return(View(model)); }
public IActionResult Add(FormulaOfGrainAddModel model) { if (!ModelState.IsValid) { return(Json(new { state = "error", data = "提交信息验证失败" })); } try { var dal = new FormulaOfGrainDal(); var p = mapper.Map <FormulaOfGrainDefinition>(model); dal.Add(p); return(Json(new { state = "ok", data = 1 })); } catch (Exception ex) { return(Json(new { state = "error", data = ex.Message })); } }