public ActionResult ModifyCps([DataSourceRequest] DataSourceRequest request, CpsModel cpsModel) { try { if (cpsModel != null) { this.cpsService = new CpsService(); var userLevel = DataTransfer.Transfer<Cps>(cpsModel, typeof(CpsModel)); this.cpsService.Modify(userLevel); } return this.Json(new[] { cpsModel }.ToDataSourceResult(request, this.ModelState)); } catch { return this.View(); } }
public ActionResult AddCps([DataSourceRequest] DataSourceRequest request, CpsModel cpsModel) { try { if (cpsModel != null) { this.cpsService = new CpsService(); var cps = DataTransfer.Transfer<Cps>(cpsModel, typeof(CpsModel)); cpsModel.ID = this.cpsService.AddCps(cps); if (cpsModel.ID > 0) { return this.Json(new[] { cpsModel }.ToDataSourceResult(request, this.ModelState)); } } } catch (Exception exception) { throw new Exception("添加Cps时发生错误", exception); } return this.View(); }