コード例 #1
0
        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));
        }
コード例 #2
0
        public IActionResult JsonIndex(string formulaId, int grainTypeId)
        {
            var formulaOfGrainDal  = new FormulaOfGrainDal();
            var formulaOfGrainList = formulaOfGrainDal.QueryByFormulaIdGrainTypeId(formulaId, grainTypeId);
            //var list = formulaOfGrainList.Select(o => new
            //{
            //    FormulaId = o.FormulaOfGrain.FormulaId,
            //    GrainId = o.FormulaOfGrain.GrainId,
            //    Amount = o.FormulaOfGrain.Amount,
            //    GrainName = o.Grain.GrainName,
            //});
            var grid = new
            {
                total = formulaOfGrainList.Count(),
                rows  = formulaOfGrainList,
            };

            return(Json(grid));
        }
コード例 #3
0
        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 }));
            }
        }
コード例 #4
0
        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 }));
            }
        }
コード例 #5
0
        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 }));
            }
        }