コード例 #1
0
ファイル: SMSService.cs プロジェクト: aspdotnetmvc/mvc
 /// <summary>
 /// 删除用户
 /// </summary>
 /// <param name="accountID"></param>
 /// <returns></returns>
 public RPCResult DelAccount(string accountID)
 {
     if (string.IsNullOrEmpty(accountID))
     {
         LogHelper.LogWarn("SMSService", "SMSService.DelAccount", "账号为空");
         return(new RPCResult(false, "删除的账号不能为空"));
     }
     try
     {
         if (AccountDB.DelAccount(accountID))
         {
             return(new RPCResult(true, "删除用户成功!"));
         }
         LogHelper.LogWarn("SMSService", "SMSService.DelAccount", "删除用户数据库操作失败");
         return(new RPCResult(false, "删除用户失败!"));
     }
     catch (Exception ex)
     {
         LogHelper.LogError("SMSService", "SMSService.DelAccount", ex.ToString());
         return(new RPCResult(false, "删除账号出现异常"));
     }
 }
コード例 #2
0
        public void AccountTest()
        {
            Account account = new Account()
            {
                AccountID = guid.ToString(),
                SMSNumber = 10
            };
            var b = AccountDB.CreateAccount(account);

            Assert.IsTrue(b);
            b = AccountDB.AccountPrepaid(account.AccountID, 10);
            Assert.IsTrue(b);
            int c = AccountDB.GetSMSNumberByAccount(account.AccountID);

            Assert.AreEqual(20, c);
            var a = AccountDB.GetAccount(account.AccountID);

            Assert.IsNotNull(a);
            Assert.AreEqual(a.AccountID, account.AccountID);
            Assert.AreEqual(a.SMSNumber, 20);

            b = AccountDB.DeductAccountSMSCharge(account.AccountID, 10);
            Assert.IsTrue(b);
            c = AccountDB.GetSMSNumberByAccount(account.AccountID);
            Assert.AreEqual(10, c);
            b = AccountDB.ReAccountSMSCharge(account.AccountID, 10);
            Assert.IsTrue(b);

            c = AccountDB.GetSMSNumberByAccount(account.AccountID);
            Assert.AreEqual(20, c);

            var accs = AccountDB.GetAccounts();

            Assert.IsNotNull(accs);
            Assert.IsTrue(accs.Count > 0);
            b = AccountDB.DelAccount(account.AccountID);
            Assert.IsTrue(b);
        }