Пример #1
0
        public void TestUserSetNickName()
        {
            var userID = new Random().Next(1, 10);
            var nickName = "小蜜蜂";
            var cmd = new UserSetNickName(userID, nickName);
            Assert.DoesNotThrow(delegate
            {
                this.commandBus.Send(cmd);
            });

            var savedUser = IoC.Resolve<IUserRepository>().FindById<User>(userID);

            Assert.NotNull(savedUser);
            Assert.Equal(savedUser.ID, userID);
            Assert.Equal(savedUser.LoginName, nickName);
        }
Пример #2
0
        public ActionResult SetNickName(string nickName)
        {
            var result = FCJsonResult.CreateFailResult(this.Lang("Unable to update your nick name. Please try again."));
            if (!string.IsNullOrEmpty(nickName.NullSafe()))
            {
                try
                {
                    var cmd = new UserSetNickName(this.CurrentUser.UserID, nickName);
                    this.CommandBus.Send(cmd);
                    this.CurrentUser.LoginName = nickName;

                    result = FCJsonResult.CreateSuccessResult(this.Lang("Nickname updated successfully."));
                }
                catch (CommandExecutionException ex)
                {
                    Log.Error("Action SetNickName Error", ex);
                }
            }
            return Json(result);
        }
Пример #3
0
        public ActionResult SetNickName(string nickName)
        {
            if (string.IsNullOrEmpty(nickName.NullSafe()))
                return Json(new FCJsonResult(-1));

            try
            {
                var cmd = new UserSetNickName(this.CurrentUser.UserID, nickName);
                this.CommandBus.Send(cmd);
                this.CurrentUser.LoginName = nickName;

                return Redirect("~/myfullcoin");
            }
            catch (CommandExecutionException ex)
            {
                return Json(new FCJsonResult(ex.ErrorCode));
            }
        }