public ActionResult Edit(int?id, int?appId, int?parentId) { var entity = new AppCodeMaster(); try { if (id.HasValue) { var appCodeMasterService = this.GetService <IAppCodeMasterService>(); entity = appCodeMasterService.Find <AppCodeMaster>(id.Value); } else { entity.AppId = appId.Value; entity.ParentId = parentId.Value; entity.ShowIndex = DateTime.Now.ToString("yyyyMMddHHmmss"); } } catch (CLApplicationException ex) { //修改时若发生异常则提示异常信息,并关闭修改界面 this.ShowAppErrorMessage(ex.Message, MessageFuncOption.CloseBrowserWindow); } return(View("~/views/appcodemaster/form.cshtml", entity)); }
public int SaveAppCodeMaster(AppCodeMaster model) { //检查是否存在重复数据 var entity = this.Find <AppCodeMaster>(model.Id); var id = model.Id; //更新数据 , 否则新增数据 if (entity != null) { //更新数据 entity = Mapper.Map <AppCodeMaster, AppCodeMaster>(model, entity); this.appCodeMasterRepository.Update(entity); } else { if (this.IsRepeatDefined(model.Code, model.ParentId)) { throw new CLApplicationException("E10071", model.Code); } //录入数据 this.appCodeMasterRepository.Insert(model); this.ServiceContext.Commit();//为了取得自增字段的值,手动提交事务 id = model.Id; } return(id); }
public JsonResult Save(AppCodeMaster model) { var result = new TreeDataModel(); var appCodeMasterService = this.GetService <IAppCodeMasterService>(); var id = appCodeMasterService.SaveAppCodeMaster(model); ShowMessage("I10010"); result = appCodeMasterService.QueryTreeModelById(id); return(Json(result)); }