Esempio n. 1
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;
            }
        }
Esempio n. 2
0
        private void ModifyPersonalAccountExecute(object parameter)
        {
            Window window = new Window()
            {
                Width   = 500,
                Height  = 600,
                Content = new ModifyAccountViewModel(LoggedInAccount, AccountsList, _accountProxy),
            };

            window.ShowDialog();

            LoggedInAccount = AccountsList.FirstOrDefault(a => a.Username.Equals(LoggedInAccount.Username));
            Object[]  parameters = parameter as Object[];
            TextBlock tb         = parameters[0] as TextBlock;

            tb.Text = $"Username: {LoggedInAccount.Username}     First name: {LoggedInAccount.FirstName}     Last name: {LoggedInAccount.LastName}";
            LogText = LoggerHelper.Instance.ClientLogBuilder;
        }
        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();
            }
        }