コード例 #1
0
        public void AccountDAO_Test()
        {
            /*Context*/
            AccountDAO target = new AccountDAO();
            /*Insert*/
            AccountDTO acc = new AccountDTO();
            acc.userName = "******";
            acc.password = "******";
            acc.accountType = "administrator";
            acc.status = "active";

            string userName = "******"; // TODO: Initialize to an appropriate value
            Assert.AreEqual(false, target.isFound(userName));
            Assert.AreEqual(true,target.presist(acc));

            Assert.AreEqual(true, target.isFound(userName));//

            /*Update*/
            acc.status = "inactive";
            target.merge(acc);

            string expectedUpdate = "inactive";
            AccountDTO upd =  target.find("griddy");
            Assert.AreEqual(expectedUpdate, upd.status);

            /*Delete*/
            Assert.AreEqual(false, target.removeByUserId("griddy"));
        }
コード例 #2
0
        /*
         * 1 Successfull
         * 2 Invalid User
         * 3 E-mail Address not found
         * 4 Unable to send E-mail - contact administrator
         * 5 E-mail successfully sent
         */
        public int forgotPassword(string userName,string message)
        {
            string newPassword = System.Web.Security.Membership.GeneratePassword(8, 2);
            int flag = 2;//Invalid user

            AccountDAO acc_context = new AccountDAO();
            ContactInfoDAO con_context = new ContactInfoDAO();

            if (acc_context.isFound(userName))
            {
                if (con_context.isFound(userName, "e-mail"))
                {
                    ContactInfoDTO email = con_context.find(userName, "e-mail");
                    AccountDTO account = acc_context.find(userName);
                    account.password = newPassword;
                    acc_context.merge(account);

                    message.Replace("PASSWORD", newPassword);
                    flag = sendMail(email.data, message);

                }
                else
                {
                    flag = 3; //Email Address not found
                }

            }
            return flag;
        }
コード例 #3
0
        public void setUserRole(String username, AccountType accountType)
        {
            AccountDAO accountDao = new AccountDAO();
            AccountDTO accountDto = accountDao.find(username);

            accountDto.accountType = accountType.ToString();
            accountDao.merge(accountDto);
        }
コード例 #4
0
        public void setAccountActive(String username)
        {
            AccountDAO accountDao = new AccountDAO();
            AccountDTO accountDto = accountDao.find(username);

            accountDto.status = AccountStatus.ACTIVE.ToString();
            accountDao.merge(accountDto);
        }
コード例 #5
0
        public void requestAccountUnlock(String username)
        {
            AccountDAO accountDao = new AccountDAO();
            AccountDTO accountDto = accountDao.find(username);

            accountDto.status = AccountStatus.UNLOCKED.ToString();
            accountDao.merge(accountDto);
        }
コード例 #6
0
        public void lockAccount(String username)
        {
            AccountDAO accountDao = new AccountDAO();
            AccountDTO accountDto = accountDao.find(username);

            accountDto.status = AccountStatus.LOCKED.ToString();
            accountDao.merge(accountDto);
        }