Ejemplo n.º 1
0
        public ActionResult ModifySmsInterface(int smsInterfaceID, string account, string password)
        {
            if (string.IsNullOrEmpty(account)) return Json(new JsonResult(-1));
            if (string.IsNullOrEmpty(password)) return Json(new JsonResult(-2));

            try
            {
                var cmd = new ModifySmsInterface(smsInterfaceID, SmsInterfaceType.IHUYI, account, password, this.CurrentUser.UserID);
                this.CommandBus.Send(cmd);
                return Json(JsonResult.Success);
            }
            catch (CommandExecutionException ex)
            {
                if (ex.ErrorCode == (int)ErrorCode.NoPermission)
                    return Json(new JsonResult(-3));
                else return Json(new JsonResult(ex.ErrorCode));
            }
        }
Ejemplo n.º 2
0
        public void TestCreateAndModifySmsInterface()
        {
            var smsAccount = "sms_account";
            var smsPassword = "******";
            var userID = 1;
            var smsInterfaceID = 1;

            var smsInterface = IoC.Resolve<IRepository>().FindById<SmsInterface>(smsInterfaceID);

            if (smsInterface == null)
            {
                var cmd = new CreateSmsInterface(SmsInterfaceType.IHUYI, smsAccount, smsPassword, userID);

                Assert.DoesNotThrow(delegate
                {
                    this.commandBus.Send(cmd);
                });
                smsInterface = IoC.Resolve<IRepository>().FindById<SmsInterface>(smsInterfaceID);
                Assert.Equal(smsInterface.Account, smsAccount);
                Assert.Equal(smsInterface.SmsType, SmsInterfaceType.IHUYI);
                Assert.Equal(smsInterface.Password, smsPassword);
            }

            var smsAccount_modify =smsAccount+ "modify";
            var smsPassword_modify = smsPassword + "modify";
            var cmdModify = new ModifySmsInterface(smsInterfaceID, SmsInterfaceType.IHUYI, smsAccount_modify, smsPassword_modify, userID);

            Assert.DoesNotThrow(delegate
            {
                this.commandBus.Send(cmdModify);
            });
            smsInterface = IoC.Resolve<IRepository>().FindById<SmsInterface>(smsInterfaceID);

            Assert.Equal(smsInterface.Account, smsAccount_modify);
            Assert.Equal(smsInterface.SmsType, SmsInterfaceType.IHUYI);
            Assert.Equal(smsInterface.Password, smsPassword_modify);
        }