Beispiel #1
0
        public IActionResult Update(string granariesId)
        {
            var dal   = new GranariesDal();
            var p     = dal.Find(granariesId);
            var model = mapper.Map <GranariesUpdateModel>(p);

            return(View(model));
        }
Beispiel #2
0
        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 }));
            }
        }
Beispiel #3
0
        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 }));
            }
        }