public async Task DeleteAsync(long id) { var user = await _userManager.GetUserByIdAsync(id); var userInfo = user.UserInfo; await _userManager.DeleteAsync(user); await _userInfoManager.Delete(userInfo.Id); }
/// <summary> ///删除用户 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MenuItemDel_Click(object sender, EventArgs e) { UserInfo _ItemInfo = null; if (this._RecordListView.SelectedObjects != null && this._RecordListView.SelectedObjects.Count > 0) { _ItemInfo = (UserInfo)this._RecordListView.SelectedObjects[0]; } else { MessageBox.Show("请选中项后再试!"); } //if (_ItemInfo.userName == "admin") //{ // MessageBox.Show("管理员不可删除!"); // return; //} ConfirmFrm confirm = new ConfirmFrm("提示", string.Format("您确定需要删除用户 {0}?", _ItemInfo.userName), "确定", "取消", 3); if (confirm.ShowDialog() == DialogResult.OK) { PermissionManager manager = new PermissionManager(); bool bolsucced = manager.DeleteItemByUserName(_ItemInfo.userName); //1.调用bll,从模块对应的权限列表中移除 UserInfoManager usermanager = new UserInfoManager(); bolsucced = usermanager.Delete(_ItemInfo.ID); if (bolsucced) { RecordList.Remove(_ItemInfo); //从用户权限列表中移除 //2.从列表中移除 this._RecordListView.RemoveObject(_ItemInfo);//将原生从列表中移除 } else { MessageBox.Show("操作失败!"); } } }
public ActionResult DeleteSysUser(UserInfo userInfo) { RoleUserManager.DeleteWithUserInfo(userInfo); UserInfoManager.Delete(userInfo.ID); return(Content("1")); }