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)); }
public IActionResult Update(long deviceId) { var dal = new DeviceDal(); var p = dal.Find(deviceId); var model = mapper.Map <DeviceUpdateModel>(p); return(View(model)); }
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 })); } }
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 })); } }
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 })); } }