public bool VerifyCustomerAccount(string accountNumber, int pin)
        {
            var customer = AuthoriseRequest();

            logger.Debug("VerifyCustomerAccount owner=" + customer.Name + ", accountNumber=" + accountNumber + ".");

            accountNumber = Regex.Replace(accountNumber, @"^\D", String.Empty);

            var customerAccount = _customerAccountDataLayer.Get(customer.Name, accountNumber);

            if (customerAccount != null && customerAccount.PIN == pin)
            {
                return(true);
            }
            else
            {
                if (customerAccount == null)
                {
                    logger.Warn("The customer account could not be found for owner " + customer.Name + " and account number " + accountNumber + ".");
                }
                else if (customerAccount.PIN != pin)
                {
                    logger.Warn("The customer account PIN did not match for owner " + customer.Name + " and account number " + accountNumber + ".");
                }

                return(false);
            }
        }
示例#2
0
        public void TestGetCustomerAccountByNumber()
        {
            string accountNumber = "000111222";

            try
            {
                var customerAccount = new CustomerAccount()
                {
                    ID          = Guid.NewGuid().ToString(), AccountName = accountNumber, Owner = "aaron", RatePlan = 1,
                    AccountCode = "AC" + accountNumber, AccountNumber = accountNumber, Inserted = DateTime.UtcNow.ToString("o")
                };

                using (var db = new SIPSorceryEntities())
                {
                    db.CustomerAccounts.Add(customerAccount);
                    db.SaveChanges();
                }

                CustomerAccountDataLayer customerAccountDataLayer = new CustomerAccountDataLayer();
                var checkCustomerAccount = customerAccountDataLayer.Get("aaron", accountNumber);

                Assert.IsNotNull(checkCustomerAccount);
                Assert.AreEqual(customerAccount.ID, checkCustomerAccount.ID);
            }
            finally
            {
                TestHelper.ExecuteQuery("delete from customeraccount where accountnumber = '" + accountNumber + "'");
            }
        }
        public void TestGetCustomerAccountByNumber()
        {
            string accountNumber = "000111222";

            try
            {
                var customerAccount = new CustomerAccount() {
                    ID = Guid.NewGuid().ToString(), AccountName = accountNumber, Owner = "aaron", RatePlan = 1,
                    AccountCode = "AC" + accountNumber, AccountNumber = accountNumber, Inserted = DateTime.UtcNow.ToString("o") };

                using (var db = new SIPSorceryEntities())
                {
                    db.CustomerAccounts.AddObject(customerAccount);
                    db.SaveChanges();
                }

                CustomerAccountDataLayer customerAccountDataLayer = new CustomerAccountDataLayer();
                var checkCustomerAccount = customerAccountDataLayer.Get("aaron", accountNumber);

                Assert.IsNotNull(checkCustomerAccount);
                Assert.AreEqual(customerAccount.ID, checkCustomerAccount.ID);
            }
            finally
            {
                TestHelper.ExecuteQuery("delete from customeraccount where accountnumber = '" + accountNumber + "'");
            }
        }