Exemple #1
0
 /// <summary>
 /// Deletes the currently selected row from ObservableCollection<AccountList>
 /// </summary>
 public void DeleteSelectedRow()
 {
     if (AccountsList.Count(s => s.isSelected) > 0)
     {
         List <AccountModel> selectedAccounts = AccountsList.Where(s => s.isSelected).ToList();
         foreach (AccountModel acct in selectedAccounts)
         {
             AccountsList.Remove(acct);
         }
     }
 }
Exemple #2
0
        private void AccountsUpdateTask()
        {
            if (UpdateHelper.Instance.AccountsListAdditionHelper.Count != 0)
            {
                foreach (Account a in UpdateHelper.Instance.AccountsListAdditionHelper)
                {
                    if (!AccountsList.Contains(a, new AccountComparer()))
                    {
                        AccountsList.Add(a);
                    }
                }
            }

            if (UpdateHelper.Instance.AccountsListModificationHelper.Count != 0)
            {
                foreach (Account a in UpdateHelper.Instance.AccountsListModificationHelper)
                {
                    if (AccountsList.Contains(a, new AccountComparer()))
                    {
                        Account foundAccount = AccountsList.FirstOrDefault(ac => ac.Username.Equals(a.Username));
                        AccountsList.Remove(foundAccount);
                    }
                }
            }

            if (UpdateHelper.Instance.AccountsListRemovalHelper.Count != 0)
            {
                foreach (Account a in UpdateHelper.Instance.AccountsListRemovalHelper)
                {
                    if (AccountsList.Contains(a, new AccountComparer()))
                    {
                        Account foundAccount = AccountsList.FirstOrDefault(ac => ac.Username.Equals(a.Username));
                        AccountsList.Remove(foundAccount);
                        AccountsList.Add(a);
                    }
                }
            }

            if (++UpdateHelper.Instance.AccountCounter >= UpdateHelper.Instance.Limit - 1)
            {
                UpdateHelper.Instance.AccountsListAdditionHelper     = new List <Account>();
                UpdateHelper.Instance.AccountsListRemovalHelper      = new List <Account>();
                UpdateHelper.Instance.AccountsListModificationHelper = new List <Account>();

                UpdateHelper.Instance.AccountCounter = 0;
            }
        }
        private void ModifyAccountExecute(object parameter)
        {
            Object[] parameters = parameter as Object[];


            Account modifiedAccount = null;

            try
            {
                modifiedAccount = AccountProxy.ModifyAccount(AccountToModify);
            }
            catch (Exception e)
            {
                logger.Error($"Error while deleting - server side. Message: {e.Message}");
                LoggerHelper.Instance.LogMessage($"Error while deleting - server side. Message: {e.Message}", EEventPriority.ERROR, EStringBuilder.CLIENT);
            }

            if (modifiedAccount != null)
            {
                Account foundAccount = AccountsList.FirstOrDefault(a => a.Username.Equals(modifiedAccount.Username));
                AccountsList.Remove(foundAccount);
                AccountsList.Add(modifiedAccount);

                logger.Info($"Account successfully modified.");
                LoggerHelper.Instance.LogMessage($"Account successfully modified.", EEventPriority.INFO, EStringBuilder.CLIENT);
                UserControl uc     = parameters[0] as UserControl;
                Window      window = Window.GetWindow(uc);
                window.Close();
            }
            else
            {
                logger.Error($"Error while deleting - server side.");
                LoggerHelper.Instance.LogMessage($"Error while deleting - server side.", EEventPriority.ERROR, EStringBuilder.CLIENT);
                UserControl uc     = parameters[0] as UserControl;
                Window      window = Window.GetWindow(uc);
                window.Close();
            }
        }