public void Update(UpdateRoleInput input) { input.Validate(); Sys_Role role = this.DbContext.QueryByKey <Sys_Role>(input.Id, true); role.NotNull("角色不存在"); this.MapValueFromInput(role, input); string[] permissionIds = input.GetPermissionIds(); List <Sys_RoleAuthorize> roleAuthorizeEntitys = this.CreateRoleAuthorizes(role.Id, permissionIds); this.DbContext.DoWithTransaction(() => { this.DbContext.Update(role); this.DbContext.Delete <Sys_RoleAuthorize>(a => a.RoleId == role.Id); foreach (var roleAuthorizeEntity in roleAuthorizeEntitys) { this.DbContext.Insert(roleAuthorizeEntity); } }); }
//[ValidateAntiForgeryToken] public ActionResult Update(UpdateRoleInput input) { input.Validate(); var services = CreateService <IAccountAppService>(); Sys_Role role = services.GetById <Sys_Role>(input.Id); role.NotNull("角色不存在"); AceMapper.Map(input, role); string[] permissionIds = input.GetPermissionIds(); List <Sys_RoleAuthorize> roleAuthorizeEntitys = CreateRoleAuthorizes(role.Id, permissionIds); role.LastModifyTime = DateTime.Now; role.LastModifyUserId = CurrentSession.UserId; services.Update(role); services.DeleteSys_RoleAuthorize(role.Id); foreach (var roleAuthorizeEntity in roleAuthorizeEntitys) { services.Insert(roleAuthorizeEntity); } return(UpdateSuccessMsg()); }