예제 #1
0
        /// <summary>
        /// Delete an account and associated entries by account GUID.
        /// </summary>
        /// <param name="guid">GUID of the account.</param>
        public void DeleteAccountByGuid(string guid)
        {
            if (String.IsNullOrEmpty(guid))
            {
                throw new ArgumentNullException(nameof(guid));
            }

            Account a = GetAccountByGuidInternal(guid);

            if (a != null)
            {
                try
                {
                    LockAccount(a.GUID);
                    DbExpression e2 = new DbExpression(_ORM.GetColumnName <Entry>(nameof(Entry.AccountGUID)), DbOperators.Equals, a.GUID);
                    _ORM.DeleteMany <Entry>(e2);
                    _ORM.Delete <Account>(a);
                }
                finally
                {
                    UnlockAccount(a.GUID);
                    Task.Run(() => AccountDeleted?.Invoke(this, new AccountEventArgs(a)));
                }
            }
        }
 private void ll_Delete_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     if (MessageBox.Show("Are you sure you want to delete the existing account?", "Delete account", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         AppModel.Instance.DeleteMasterAccount();
         AccountDeleted?.Invoke();
     }
 }
예제 #3
0
 public void DeleteAccount(Predicate <Account> predicate)
 {
     if (Data is List <Account> dataList)
     {
         foreach (var item in dataList)
         {
             if (predicate(item))
             {
                 dataList.Remove(item);
                 AccountDeleted?.Invoke(this, new AccountManagerEventArgs(item, AccountManagerEventType.AccountDeleted));
                 return;
             }
         }
     }
 }
예제 #4
0
        private void BgwAccountUpdater_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            switch (e.UserState.ToString())
            {
            case "ACCOUNT_CREATED":
                AccountCreated?.Invoke(this, new AccountEventArgs(accountData));
                break;

            case "ACCOUNT_DELETED":
                AccountDeleted?.Invoke(this, new AccountEventArgs(accountData));
                break;

            case "ACCOUNT_INFO_UPDATED":
                AccountInfoUpdated?.Invoke(this, new AccountEventArgs(accountData));
                break;

            default:
                throw (new ArgumentException());
            }
        }