コード例 #1
0
        public async Task OnAppearingAsync()
        {
            try
            {
                if (isRunning)
                {
                    return;
                }

                isRunning = true;

                List <AccountViewModel> accountVms = mapper.Map <List <AccountViewModel> >(await mediator.Send(new GetAccountsQuery()));
                accountVms.ForEach(async x => x.EndOfMonthBalance = await mediator.Send(new GetAccountEndOfMonthBalanceQuery(x.Id)));

                var includedAccountGroup = new AlphaGroupListGroupCollection <AccountViewModel>(Strings.IncludedAccountsHeader);
                var excludedAccountGroup = new AlphaGroupListGroupCollection <AccountViewModel>(Strings.ExcludedAccountsHeader);

                includedAccountGroup.AddRange(accountVms.Where(x => !x.IsExcluded));
                excludedAccountGroup.AddRange(accountVms.Where(x => x.IsExcluded));

                var newAccountCollection = new ObservableCollection <AlphaGroupListGroupCollection <AccountViewModel> >();

                if (includedAccountGroup.Any())
                {
                    newAccountCollection.Add(includedAccountGroup);
                }

                if (excludedAccountGroup.Any())
                {
                    newAccountCollection.Add(excludedAccountGroup);
                }
                // Don't clear and add items separately since iOS doesn't handle batch updates correctly.
                Accounts = newAccountCollection;
            }
            finally
            {
                isRunning = false;
            }
        }
コード例 #2
0
        public async Task OnAppearingAsync()
        {
            try
            {
                if (isRunning)
                {
                    return;
                }

                isRunning = true;

                Accounts.Clear();

                List <AccountViewModel>?accountVms = mapper.Map <List <AccountViewModel> >(await mediator.Send(new GetAccountsQuery()));
                accountVms.ForEach(async x => x.EndOfMonthBalance = await mediator.Send(new GetAccountEndOfMonthBalanceQuery(x.Id)));

                var includedAccountGroup = new AlphaGroupListGroupCollection <AccountViewModel>(Strings.IncludedAccountsHeader);
                var excludedAccountGroup = new AlphaGroupListGroupCollection <AccountViewModel>(Strings.ExcludedAccountsHeader);

                includedAccountGroup.AddRange(accountVms.Where(x => !x.IsExcluded));
                excludedAccountGroup.AddRange(accountVms.Where(x => x.IsExcluded));

                if (includedAccountGroup.Any())
                {
                    Accounts.Add(includedAccountGroup);
                }

                if (excludedAccountGroup.Any())
                {
                    Accounts.Add(excludedAccountGroup);
                }
            }
            finally
            {
                isRunning = false;
            }
        }