public ActionResult ResetNickName(string id, FormCollection Collection) { BzureUser user = Actor.Public.AsUserManager().GetUserByID(id); if (user.IsNull()) { return RedirectToAction("UserList"); } string newNickName = Collection["NewNickName"]; string msg = string.Format("用户:{0}设置昵称:{1}失败", user.UserName, newNickName); if (Actor.Public.AsUserManager().ExistsNickName(newNickName)) { msg = string.Format("用户:{0}设置昵称:{1}失败,因为昵称已经被占用", user.UserName, newNickName); } else { if (Actor.Public.AsUserManager().SetNickName(user.UserName, newNickName)) { msg = string.Format("用户:{0}昵称重置成功", user.UserName); } else { msg = string.Format("用户:{0}设置昵称:{1}失败,可能是因为软件内部错误", user.UserName, newNickName); } } ResetNickNameViewModel ViewModel = new ResetNickNameViewModel() { Title = "重置昵称", MasterViewModel = this.MasterViewModel, UserName = user.UserName, Url = Url.RouteUrl("SecurityApp_User", new { action = "ResetNickName", id = user.UserID }), Message = msg }; return Result(ViewModel); }
public ActionResult ResetNickName() { if (!Actor.Public.IsAuthenticated) return RedirectToAction("UserList"); BzureUser user = Actor.Me.AsBzurePrincipal().ToUserModel().Entity; if (user.IsNull()) { return RedirectToAction("UserList"); } ResetNickNameViewModel ViewModel = new ResetNickNameViewModel() { Title = "重置昵称", MasterViewModel = this.MasterViewModel, UserName = user.UserName, NickName = user.NickName, Url = Url.RouteUrl("SecurityApp_User", new { action = "ResetNickName", id = user.UserID }) }; return Result(ViewModel); }