コード例 #1
0
        Task IEventHandler <OutcomeWhenChanged> .HandleAsync(OutcomeWhenChanged payload)
        {
            OutcomeOverviewViewModel viewModel = Items.FirstOrDefault(vm => payload.AggregateKey.Equals(vm.Key));

            if (viewModel != null)
            {
                viewModel.When = payload.When;
                if (Period is MonthModel month)
                {
                    MonthModel newValue = payload.When;
                    if (month != newValue)
                    {
                        Items.Remove(viewModel);
                    }
                }
                else if (Period is YearModel year)
                {
                    YearModel newValue = new YearModel(payload.When.Year);
                    if (year != newValue)
                    {
                        Items.Remove(viewModel);
                    }
                }
            }

            return(Task.CompletedTask);
        }
コード例 #2
0
        Task IEventHandler <OutcomeDescriptionChanged> .HandleAsync(OutcomeDescriptionChanged payload)
        {
            OutcomeOverviewViewModel viewModel = Items.FirstOrDefault(vm => payload.AggregateKey.Equals(vm.Key));

            if (viewModel != null)
            {
                viewModel.Description = payload.Description;
            }

            return(Task.CompletedTask);
        }
コード例 #3
0
        Task IEventHandler <OutcomeAmountChanged> .HandleAsync(OutcomeAmountChanged payload)
        {
            OutcomeOverviewViewModel viewModel = Items.FirstOrDefault(vm => payload.AggregateKey.Equals(vm.Key));

            if (viewModel != null)
            {
                viewModel.Amount = payload.NewValue;
                Sort(lastSortDescriptor);
            }

            return(Task.CompletedTask);
        }