private void LoadPayments() { EditCommand = null; //Refresh balance control with the current account BalanceViewModel.UpdateBalanceCommand.Execute(); RelatedPayments = new ObservableCollection <PaymentViewModel>(paymentRepository .GetList(x => (x.ChargedAccountId == AccountId) || (x.TargetAccountId == AccountId)) .OrderByDescending(x => x.Date) .ToList()); foreach (var payment in RelatedPayments) { payment.CurrentAccountId = AccountId; } Source = new ObservableCollection <DateListGroup <PaymentViewModel> >( DateListGroup <PaymentViewModel> .CreateGroups(RelatedPayments, CultureInfo.CurrentUICulture, s => s.Date.ToString("MMMM", CultureInfo.InvariantCulture) + " " + s.Date.Year, s => s.Date, true)); //We have to set the command here to ensure that the selection changed event is triggered earlier EditCommand = new MvxCommand <PaymentViewModel>(Edit); }
private void LoadPayments() { //Refresh balance control with the current account BalanceViewModel.UpdateBalanceCommand.Execute(); RelatedPayments = new ObservableCollection <PaymentViewModel>(paymentRepository .GetList(x => (x.ChargedAccountId == AccountId) || (x.TargetAccountId == AccountId)) .OrderByDescending(x => x.Date) .ToList()); foreach (var payment in RelatedPayments) { payment.CurrentAccountId = AccountId; } var dailyList = DateListGroup <PaymentViewModel> .CreateGroups(RelatedPayments, CultureInfo.CurrentUICulture, s => s.Date.ToString("D", CultureInfo.InvariantCulture), s => s.Date, itemClickCommand : EditPaymentCommand, itemLongClickCommand : OpenContextMenuCommand); Source = new ObservableCollection <DateListGroup <DateListGroup <PaymentViewModel> > >( DateListGroup <DateListGroup <PaymentViewModel> > .CreateGroups(dailyList, CultureInfo.CurrentUICulture, s => { var date = Convert.ToDateTime(s.Key); return(date.ToString("MMMM", CultureInfo.InvariantCulture) + " " + date.Year); }, s => Convert.ToDateTime(s.Key))); }
private async void LoadPayments() { //Refresh balance control with the current account BalanceViewModel.UpdateBalanceCommand.Execute(); var account = await accountService.GetById(AccountId); Title = account.Data.Name; RelatedPayments = new ObservableCollection <PaymentViewModel>( account.Data.ChargedPayments .Concat(account.Data.TargetedPayments) .OrderByDescending(x => x.Date) .Select(x => new PaymentViewModel(new Payment(x)))); foreach (var payment in RelatedPayments) { payment.CurrentAccountId = AccountId; } var dailyList = DateListGroup <PaymentViewModel> .CreateGroups(RelatedPayments, CultureInfo.CurrentUICulture, s => s.Date.ToString("D", CultureInfo.InvariantCulture), s => s.Date, itemClickCommand : EditPaymentCommand, itemLongClickCommand : OpenContextMenuCommand); Source = new ObservableCollection <DateListGroup <DateListGroup <PaymentViewModel> > >( DateListGroup <DateListGroup <PaymentViewModel> > .CreateGroups(dailyList, CultureInfo.CurrentUICulture, s => { var date = Convert.ToDateTime(s.Key); return(date.ToString("MMMM", CultureInfo.InvariantCulture) + " " + date.Year); }, s => Convert.ToDateTime(s.Key))); }