public IActionResult Update(string formulaId, string grainId)
        {
            var formulaOfGrainDal = new FormulaOfGrainDal();
            var grainDal          = new GrainDal();
            var formulaOfGrain    = formulaOfGrainDal.Find(formulaId, grainId);
            var model             = mapper.Map <FormulaOfGrainUpdateModel>(formulaOfGrain);
            var p = grainDal.Find(grainId);

            model.GrainName   = p.GrainName;
            model.GrainTypeId = p.GrainTypeId;
            return(View(model));
        }
        public IActionResult Update(FormulaOfGrainUpdateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { state = "error", data = "提交信息验证失败" }));
            }

            try
            {
                var dal = new FormulaOfGrainDal();
                var p   = dal.Find(model.FormulaId, model.GrainId);
                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 }));
            }
        }
        public IActionResult Delete(string formulaId, string grainId)
        {
            var dal = new FormulaOfGrainDal();
            var p   = dal.Find(formulaId, grainId);

            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 }));
            }
        }