コード例 #1
0
ファイル: SMSService.cs プロジェクト: aspdotnetmvc/mvc
        /// <summary>
        /// 创建用户
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public RPCResult <Guid> CreateAccount(Account account)
        {
            Guid guid = System.Guid.NewGuid();

            if (string.IsNullOrWhiteSpace(account.AccountID))
            {
                account.AccountID = guid.ToString();
            }
            else
            {
                guid = Guid.Parse(account.AccountID);
            }
            account.SMSNumber = 0;
            try
            {
                if (AccountDB.CreateAccount(account))
                {
                    return(new RPCResult <Guid>(true, guid, "创建用户成功!"));
                }
                LogHelper.LogWarn("SMSService", "SMSService.CreateAccount", "创建账号数据库失败");
                return(new RPCResult <Guid>(false, guid, "创建账号失败!"));
            }
            catch (Exception ex)
            {
                LogHelper.LogError("SMSService", "SMSService.CreateAccount", ex.ToString());
                return(new RPCResult <Guid>(false, guid, "创建账号异常"));
            }
        }
コード例 #2
0
ファイル: RestfulServices.cs プロジェクト: cartmansp6/test6
        public String AddAccount(Account account)
        {
            var successful = AccountDB.CreateAccount(ref account);

            return(successful ?
                   "Account " + account.Acctno + " created for user " + account.Username :
                   "******" + account.Username + " does not exist");
        }
コード例 #3
0
ファイル: PlatformSession.cs プロジェクト: neshlabs/nesh
        public async Task <Account> VerifyAccount(Platform platform, string platform_id)
        {
            Account account = await AccountDB.GetByPlatformId(platform_id);

            if (account == null)
            {
                account = await AccountDB.CreateAccount(platform, platform_id);
            }

            return(account);
        }
コード例 #4
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);
        }
コード例 #5
0
        public ActionResult Register(RegisterViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.errMessage = "Please enter valid information.";
                return(View(model));
            }

            // Validate whether account already exists.
            Account existingAccount = AccountDB.CheckAccountAvailability(model.username, model.email);

            // If no match, then create a new account.
            if (existingAccount == null)
            {
                Account myAccount = new Account
                {
                    Username     = model.username,
                    Name         = model.name,
                    Email        = model.email,
                    PasswordHash = model.psw,
                    PhoneNumber  = model.phoneNbr,
                    Carrier      = model.carrier
                };

                if (model.isEmailNotiType)
                {
                    myAccount.NotificationType |= NotificationType.Email;
                }
                if (model.isTextNotiType)
                {
                    myAccount.NotificationType |= NotificationType.SMS;
                }
                if (model.isSYLocation)
                {
                    myAccount.Location |= Location.Sylvania;
                }
                if (model.isRCLocation)
                {
                    myAccount.Location |= Location.RockCreek;
                }
                if (model.isCASLocation)
                {
                    myAccount.Location |= Location.Cascade;
                }
                if (model.isSELocation)
                {
                    myAccount.Location |= Location.Southeast;
                }

                myAccount.Code = Guid.NewGuid().ToString();
                AccountDB.CreateAccount(myAccount);
                string subject = "Please confirm your email.";
                string url     = "http://*****:*****@"

<p><a href='" + url + @"'>" + url + @"<a/></p>

hANNGry
";
                EmailNotifier.SendHtmlEmail(myAccount.Email, subject, body);
                model.message = "Register successfully";
            }
            // Validate for an existing email.
            else if (model.email == existingAccount.Email)
            {
                model.errMessage = "Email already exists. Please enter a new one.";
            }
            // Validate for an existing username.
            else if (model.username == existingAccount.Username)
            {
                model.errMessage = "Username already exists. Please enter a new one.";
            }
            // Validate for an existing phone number.
            else if (model.phoneNbr == existingAccount.PhoneNumber)
            {
                model.errMessage = "Phone number already exists. Please enter a new one.";
            }
            return(View(model));
        }