Пример #1
0
        public AccountDetailViewModel(Types.DetialViewType viewType, Account account)
            : this(viewType)
        {
            selectedAccount = account;

            email = account.Email;
            password = account.Password;
            securityQuestion = account.SecurityQuestion;
        }
Пример #2
0
 /// <summary>
 /// delete an account
 /// </summary>
 /// <param name="account"></param>
 public void DeleteAccount(Account account)
 {
     var matchedAccount = context.Accounts.First(a => a.AccountId == account.AccountId);
     if (matchedAccount != null)
     {
         context.Accounts.DeleteObject(account);
         context.SaveChanges();
     }
 }
Пример #3
0
        public void TestInsertAccount()
        {
            Account account = new Account
            {
                Email = "*****@*****.**",
                Password = "******",
                SecurityQuestion = "Insert"
            };

            accountRepository.InsertAccount(account);
        }
Пример #4
0
 /// <summary>
 /// read accounts from csv file
 /// csv file's structure is following
 /// Email, Password, SecurityQuestion
 /// </summary>
 /// <param name="csvFilePath"></param>
 /// <returns></returns>
 public IList<Account> GetAccounts(string csvFilePath)
 {
     IList<Account> accounts = new List<Account>();
     CSVHelper csvHelper = new CSVHelper(csvFilePath);
     foreach (string[] line in csvHelper)
     {
         Account account = new Account()
         {
             Email = line[0],
             Password = line[1],
             SecurityQuestion = line[2]
         };
         accounts.Add(account);
     }
     return accounts;
 }
Пример #5
0
 /// <summary>
 /// update an account
 /// </summary>
 /// <param name="account"></param>
 public void UpdateAccount(Account account)
 {
     var matchedAccount = context.Accounts.First(a => a.AccountId == account.AccountId);
     matchedAccount = account;
     context.SaveChanges();
 }
Пример #6
0
 /// <summary>
 /// insert an account
 /// </summary>
 /// <param name="account"></param>
 public void InsertAccount(Account account)
 {
     context.Accounts.AddObject(account);
     context.SaveChanges();
 }
Пример #7
0
 /// <summary>
 /// Create a new Account object.
 /// </summary>
 /// <param name="accountId">Initial value of the AccountId property.</param>
 /// <param name="email">Initial value of the Email property.</param>
 /// <param name="password">Initial value of the Password property.</param>
 /// <param name="securityQuestion">Initial value of the SecurityQuestion property.</param>
 public static Account CreateAccount(global::System.Int32 accountId, global::System.String email, global::System.String password, global::System.String securityQuestion)
 {
     Account account = new Account();
     account.AccountId = accountId;
     account.Email = email;
     account.Password = password;
     account.SecurityQuestion = securityQuestion;
     return account;
 }
Пример #8
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Accounts EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToAccounts(Account account)
 {
     base.AddObject("Accounts", account);
 }
Пример #9
0
        /// <summary>
        /// add an account
        /// </summary>
        private void AddAccount()
        {
            PropertyChangedCompleted();

            // if all fields are valid
            if (this.IsValid == true)
            {
                try
                {
                    // if already the account with the same email address exists
                    if (accountRepository.IsExistAccount(email) == true)
                    {
                        ErrorMessage = "Registered email address.";
                    }
                    else
                    {
                        selectedAccount = new Account()
                        {
                            Email = email,
                            Password = password,
                            SecurityQuestion = securityQuestion
                        };

                        accountRepository.InsertAccount(selectedAccount);
                        App.Current.MainWindow.DialogResult = true;
                        App.Current.MainWindow.Close();
                    }
                }
                catch
                {
                    ErrorMessage = "Occurred database error.";
                }
            }
            else
            {
                ErrorMessage = "Invalid account information.";
            }
        }