Exemplo n.º 1
0
        public bool DoesUserNameExist(string username, out TestSprocGenerator.Business.SingleTable.Bo.Account account)
        {
            account = null;
            if (_smoSettings.ContainsKey(CONNECTION_STRING_NAME))
            {
                TestSprocGenerator.Business.SingleTable.Bo.Account criteria =
                    new TestSprocGenerator.Business.SingleTable.Bo.Account(_smoSettings[CONNECTION_STRING_NAME])
                {
                    AccountUsername = username
                };

                TestSprocGenerator.Business.SingleTable.Bo.List.Account searchReturned =
                    new TestSprocGenerator.Business.SingleTable.Bo.List.Account(_smoSettings[CONNECTION_STRING_NAME]);

                searchReturned.FillByCriteriaExact(criteria);

                if (searchReturned != null && searchReturned.Count > 0)
                {
                    account = (TestSprocGenerator.Business.SingleTable.Bo.Account)searchReturned[0];
                    return(true);
                }
                return(false);
            }
            else
            {
                throw new ApplicationException("Database Connection String Not in Configuration File or not loaded from Config File");
            }

            return(false);
        }
Exemplo n.º 2
0
        private TestSprocGenerator.Business.SingleTable.Bo.Account GetAccountAccountByAccountID(Guid accountID)
        {
            TestSprocGenerator.Business.SingleTable.Bo.Account foundAccount = null;

            //get the user by username first then we can figure out if the password is ok
            TestSprocGenerator.Business.SingleTable.Bo.Account accountSearchCriteria =
                new TestSprocGenerator.Business.SingleTable.Bo.Account(_smoSettings[CONNECTION_STRING_NAME])
            {
                AccountID = accountID
            };

            TestSprocGenerator.Business.SingleTable.Bo.List.Account searchReturned =
                new TestSprocGenerator.Business.SingleTable.Bo.List.Account(_smoSettings[CONNECTION_STRING_NAME]);

            searchReturned.FillByCriteriaExact(accountSearchCriteria);

            if (searchReturned != null && searchReturned.Count > 0)
            {
                //there should only be one
                if (searchReturned.Count == 1)
                {
                    foundAccount = (TestSprocGenerator.Business.SingleTable.Bo.Account)searchReturned[0];
                }
                else
                {
                    throw new ApplicationException("There should only be one account with that accountID, but there is more than one, contact administrator");
                }
            }
            return(foundAccount);
        }
Exemplo n.º 3
0
        public List <TestSprocGenerator.Business.SingleTable.Bo.Account> AccountRetrieveByCriteria(TestSprocGenerator.Business.SingleTable.Bo.Account accountModel)
        {
            if (_smoSettings.ContainsKey(CONNECTION_STRING_NAME))
            {
                TestSprocGenerator.Business.SingleTable.Bo.List.Account searchReturned =
                    new TestSprocGenerator.Business.SingleTable.Bo.List.Account(_smoSettings[CONNECTION_STRING_NAME]);

                searchReturned.FillByCriteriaExact(accountModel);
            }
            throw new ApplicationException("Database Connection String Not in Configuration File or not loaded from Config File");
        }
Exemplo n.º 4
0
        public bool LoginUser(string username, string password)
        {
            if (_smoSettings.ContainsKey(CONNECTION_STRING_NAME))
            {
                if (string.IsNullOrEmpty(username))
                {
                    throw new ArgumentNullException("Username");
                }

                if (string.IsNullOrEmpty(password))
                {
                    throw new ArgumentNullException("Password");
                }

                //get the user by username first then we can figure out if the password is ok
                TestSprocGenerator.Business.SingleTable.Bo.Account criteria =
                    new TestSprocGenerator.Business.SingleTable.Bo.Account(_smoSettings[CONNECTION_STRING_NAME])
                {
                    AccountUsername = username, Deleted = false
                };

                TestSprocGenerator.Business.SingleTable.Bo.List.Account searchReturned =
                    new TestSprocGenerator.Business.SingleTable.Bo.List.Account(_smoSettings[CONNECTION_STRING_NAME]);

                searchReturned.FillByCriteriaExact(criteria);


                if (searchReturned != null && searchReturned.Count > 0)
                {
                    //now that we have a user with that username we need to compare/verify the hashed password
                    if (!string.IsNullOrEmpty(searchReturned[0].AccountPassword))
                    {
                        string salt = searchReturned[0].AccountPassword.Substring(searchReturned[0].AccountPassword.Length -
                                                                                  CommonLibrary.Security.HashSaltHelper.SALT_SIZE);

                        string hashedPasswordAndSalt = HashSaltHelper.CreatePasswordHash(password, salt);

                        bool passwordMatch = hashedPasswordAndSalt.Equals(searchReturned[0].AccountPassword);
                        if (passwordMatch)
                        {
                            return(true);
                        }
                    }
                }

                return(false);
            }
            else
            {
                throw new ApplicationException("Database Connection String Not in Configuration File or not loaded from Config File");
            }

            return(false);
        }
Exemplo n.º 5
0
        public bool AccountDeleteByCriteria(TestSprocGenerator.Business.SingleTable.Bo.Account accountModel)
        {
            if (_smoSettings.ContainsKey(CONNECTION_STRING_NAME))
            {
                accountModel.DatabaseSmoObjectsAndSettings = _smoSettings[CONNECTION_STRING_NAME];
                //do a get first cause there may be more than one record this may cause an issue
                TestSprocGenerator.Business.SingleTable.Bo.List.Account listReturned =
                    new TestSprocGenerator.Business.SingleTable.Bo.List.Account(accountModel.DatabaseSmoObjectsAndSettings);

                listReturned.FillByCriteriaExact(accountModel);

                foreach (TestSprocGenerator.Business.SingleTable.Bo.Account accountToDelete in listReturned)
                {
                    accountToDelete.Delete();
                }
                return(true);
            }
            else
            {
                throw new ApplicationException("Database Connection String Not in Configuration File or not loaded from Config File");
            }

            return(false);
        }