コード例 #1
0
        public IActionResult JsonIndex(DeviceJsonIndexModel model)
        {
            //if (model.BeginDateTime == null)
            //    model.BeginDateTime = DateTime.Now.ToString("yyyy-MM-dd");
            //if (model.EndDateTime == null)
            //    model.EndDateTime = DateTime.Now.ToString("yyyy-MM-dd");
            var dal   = new DeviceDal();
            var param = new DeviceDal.QueryByParam1In()
            {
                //BeginDateTime = DateTime.Parse(model.BeginDateTime),
                //EndDateTime = DateTime.Parse(model.EndDateTime),
                Rows = model.Rows,
                Page = model.Page,
            };
            var list  = dal.QueryByParam1(param);
            var list2 = from o in list
                        select new
            {
                DeviceId   = o.DeviceId,
                DeviceName = o.DeviceName,
            };

            var grid = new
            {
                total = param.Total,
                rows  = list2,
            };

            return(Json(grid));
        }
コード例 #2
0
        public IActionResult Update(long deviceId)
        {
            var dal   = new DeviceDal();
            var p     = dal.Find(deviceId);
            var model = mapper.Map <DeviceUpdateModel>(p);

            return(View(model));
        }
コード例 #3
0
        public IActionResult Add(DeviceAddModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { state = "error", data = "提交信息验证失败" }));
            }

            try
            {
                var dal = new DeviceDal();
                var p   = mapper.Map <DeviceDefinition>(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 Delete(long deviceId)
        {
            var dal = new DeviceDal();
            var p   = dal.Find(deviceId);

            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 }));
            }
        }
コード例 #5
0
        public IActionResult Update(DeviceUpdateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { state = "error", data = "提交信息验证失败" }));
            }

            try
            {
                var dal = new DeviceDal();
                var p   = dal.Find(model.DeviceId);
                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 }));
            }
        }